diff options
Diffstat (limited to 'sesman/tcp.c')
| -rw-r--r-- | sesman/tcp.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/sesman/tcp.c b/sesman/tcp.c index 36ea4670..e51fbdf9 100644 --- a/sesman/tcp.c +++ b/sesman/tcp.c @@ -21,12 +21,18 @@ * * @file tcp.c * @brief Tcp stream funcions - * @author Jay Sorg - * + * @author Jay Sorg, Simone Fedele + * */ #include "sesman.h" +#include <netinet/in.h> +#include <sys/socket.h> +#include <arpa/inet.h> +#include <stdlib.h> +#include <string.h> + /*****************************************************************************/ int DEFAULT_CC tcp_force_recv(int sck, char* data, int len) @@ -124,3 +130,16 @@ tcp_force_send(int sck, char* data, int len) return 0; } + +/*****************************************************************************/ +int DEFAULT_CC +tcp_bind(int sck, char* addr, char* port) +{ + struct sockaddr_in s; + + memset(&s, 0, sizeof(struct sockaddr_in)); + s.sin_family = AF_INET; + s.sin_port = htons(atoi(port)); + s.sin_addr.s_addr = inet_addr(addr); + return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in)); +} |
