Int main()
{
Int servfd;
Struct Sockaddr_in server_addr,client_addr;
Char buf[] = " ";
Int len = sizeof(server_addr)
Bzero(&server_addr,sizeof(server_addr));
Bzero(&client_addr, sizeof(client_addr));
Servfd = socket(AF_INET, SOCK_DGRAM, 0 );
Server_addr.sin_famliy = AF_INET;
Server_addr.sin_port = htons(2222);
Server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
Blind(server_addr, (struct sockaddr *)&server_addr, len);
While(1)
{
Recvfrom(servfd, buf, 100, 0, (struct sockaddr *)&client_addr, sizeof(client_addr));
Printf("recv %s\n",buf);
Sleep(1);
Sendto(servfd, "OK", 3, 0, (strucsockadd*)&client_addr,sizeof(client_addr));
}
Return 1;
}
|