diff options
Diffstat (limited to 'nacl/curvecp/socket_bind.c')
-rw-r--r-- | nacl/curvecp/socket_bind.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/nacl/curvecp/socket_bind.c b/nacl/curvecp/socket_bind.c new file mode 100644 index 00000000..9e36925d --- /dev/null +++ b/nacl/curvecp/socket_bind.c | |||
@@ -0,0 +1,15 @@ | |||
1 | #include <sys/types.h> | ||
2 | #include <sys/socket.h> | ||
3 | #include <netinet/in.h> | ||
4 | #include <errno.h> | ||
5 | #include "socket.h" | ||
6 | #include "byte.h" | ||
7 | |||
8 | int socket_bind(int fd,const unsigned char *ip,const unsigned char *port) | ||
9 | { | ||
10 | struct sockaddr_in sa; | ||
11 | byte_zero(&sa,sizeof sa); | ||
12 | byte_copy(&sa.sin_addr,4,ip); | ||
13 | byte_copy(&sa.sin_port,2,port); | ||
14 | return bind(fd,(struct sockaddr *) &sa,sizeof sa); | ||
15 | } | ||