diff options
Diffstat (limited to 'include/tcp.h')
-rw-r--r-- | include/tcp.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/tcp.h b/include/tcp.h new file mode 100644 index 0000000..20c6092 --- /dev/null +++ b/include/tcp.h @@ -0,0 +1,41 @@ +#ifndef _TCP_H_ +#define _TCP_H_ + +#include <arpa/inet.h> + +struct tcp_conf { + int ipproto; + unsigned short port; + union { + struct { + struct in_addr inet_addr; + } ipv4; + struct { + struct in6_addr inet_addr6; + int scope_id; + } ipv6; + } server; + union { + struct in_addr inet_addr; + struct in6_addr inet_addr6; + } client; +}; + +struct tcp_server; + +struct tcp_server *tcp_server_create(struct tcp_conf *conf); +void tcp_server_destroy(struct tcp_server *c); +int tcp_server_get_fd(struct tcp_server *c); +int tcp_server_accept(struct tcp_server *c, struct sockaddr_in *addr); + +struct tcp_client; + +struct tcp_client *tcp_client_create(struct tcp_conf *conf); +void tcp_client_destroy(struct tcp_client *c); +int tcp_client_get_fd(struct tcp_client *c); +ssize_t tcp_client_send(struct tcp_client *c, const void *data, int size); +ssize_t tcp_client_recv(struct tcp_client *c, void *data, int size); +void tcp_client_set_data(struct tcp_client *c, void *data); +void *tcp_client_get_data(struct tcp_client *c); + +#endif /*_TCP_H_ */ |