udp server and client
client #include<stdio.h> #include<unistd.h> #include<stdlib.h> #include<sys/socket.h> #include<netinet/in.h> #include<arpa/inet.h> int main() { int sfd = socket(AF_INET,SOCK_DGRAM,0); if(sfd == -1) { perror("socked failed : "); exit(1); } else { printf("socket created successfully : sfd : %d\n",sfd); while(1) { struct sockaddr_in server; server.sin_family = AF_INET; server.sin_port = htons(8000); server.sin_addr.s_addr = inet_addr("192.168.0.122"); char buff[50] = ""; printf("enter the message to server : \n"); fgets(buff,50,stdin); int snd = sendto(sfd,buff,sizeof(buff),0,(struct sockaddr *)&server,sizeof(server)); if(snd == -1) { perror(" sendto failed : "); exit(1); } ...