mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-22 06:27:51 +00:00
bf9710fd5a
This only affects build_android, if nacl-gcc-prep is run then build/`uname -s` will be created.
24 lines
560 B
C
24 lines
560 B
C
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#include <errno.h>
|
|
#include "socket.h"
|
|
#include "byte.h"
|
|
|
|
long long socket_recv(int fd,unsigned char *x,long long xlen,unsigned char *ip,unsigned char *port)
|
|
{
|
|
struct sockaddr_in sa;
|
|
socklen_t salen;
|
|
int r;
|
|
|
|
if (xlen < 0) { errno = EPROTO; return -1; }
|
|
if (xlen > 1048576) xlen = 1048576;
|
|
|
|
byte_zero(&sa,sizeof sa);
|
|
salen = sizeof sa;
|
|
r = recvfrom(fd,x,xlen,0,(struct sockaddr *) &sa,&salen);
|
|
byte_copy(ip,4,&sa.sin_addr);
|
|
byte_copy(port,2,&sa.sin_port);
|
|
return r;
|
|
}
|