/* Construct the address for use with sendto/recvfrom */
struct sockaddr_in address;
address.sin_family = AF_INET;
address.sin_addr.s_addr = htonl(INADDR_ANY);
address.sin_port = htons(SRV_PORT);
int len = sizeof(address);
/* Bind address to socket */
bind(sockfd, (struct sockaddr *)&address, sizeof(address));
/* serving */
while(1) {
/* receive */
recvfrom(sockfd, buffer, sizeof(buffer), 0,
(struct sockaddr *)&address, (socklen_t *)&len);
/* handle */
sprintf(buffer, "i am server");