- 论坛徽章:
- 0
|
struct sockaddr_in sin ;
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = 5000;
udpsocket = socket (PF_INET , SOCK_DGRAM , 0);
if(udpsocket<0)
printf("---------------socket less than 0");
if( bind (udpsocket , (struct sockaddr *)&sin , sizeof( sin)) < 0)
printf("---------------bind failed");
int udpsocket ;
struct sockaddr sendaddr ;
char data[256];
socklen_t len;
len = sizeof (sendaddr);
recvfrom ( udpsocket , data , 256 ,0, (struct sockaddr *) & sendaddr ,&len) |
|