Commit | Line | Data |
---|---|---|
dc0d77d7 CE |
1 | #include <sys/types.h> |
2 | #include <sys/param.h> | |
3 | #include <sys/socket.h> | |
4 | #include <netinet/in.h> | |
5 | #include "byte.h" | |
6 | #include "socket.h" | |
7 | ||
8 | int socket_recv4(int s,char *buf,int len,char ip[4],uint16 *port) | |
9 | { | |
10 | struct sockaddr_in sa; | |
11 | int dummy = sizeof sa; | |
12 | int r; | |
13 | ||
14 | r = recvfrom(s,buf,len,0,(struct sockaddr *) &sa,&dummy); | |
15 | if (r == -1) return -1; | |
16 | ||
17 | byte_copy(ip,4,(char *) &sa.sin_addr); | |
18 | uint16_unpack_big((char *) &sa.sin_port,port); | |
19 | ||
20 | return r; | |
21 | } |