diff options
Diffstat (limited to 'nacl/curvecp/socket_send.c')
-rw-r--r-- | nacl/curvecp/socket_send.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/nacl/curvecp/socket_send.c b/nacl/curvecp/socket_send.c new file mode 100644 index 00000000..1521384c --- /dev/null +++ b/nacl/curvecp/socket_send.c | |||
@@ -0,0 +1,19 @@ | |||
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_send(int fd,const unsigned char *x,long long xlen,const unsigned char *ip,const unsigned char *port) | ||
9 | { | ||
10 | struct sockaddr_in sa; | ||
11 | |||
12 | if (xlen < 0 || xlen > 1048576) { errno = EPROTO; return -1; } | ||
13 | |||
14 | byte_zero(&sa,sizeof sa); | ||
15 | sa.sin_family = AF_INET; | ||
16 | byte_copy(&sa.sin_addr,4,ip); | ||
17 | byte_copy(&sa.sin_port,2,port); | ||
18 | return sendto(fd,x,xlen,0,(struct sockaddr *) &sa,sizeof sa); | ||
19 | } | ||