You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
440 B
C
17 lines
440 B
C
#include <sys/types.h>
|
|
#include <sys/param.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#include "socket.h"
|
|
|
|
int socket_recv4(int s,char *buf,unsigned int len,char ip[4],uint16 *port) {
|
|
struct sockaddr_in si;
|
|
unsigned int Len = sizeof si;
|
|
int r;
|
|
|
|
if ((r = recvfrom(s,buf,len,0,(struct sockaddr *) &si,&Len))<0) return -1;
|
|
*(uint32*)ip = *(uint32*)&si.sin_addr;
|
|
uint16_unpack_big((char *) &si.sin_port,port);
|
|
return r;
|
|
}
|