#include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #include<stdio.h> #include<string.

h> int main(int argc,char **argv) {

sockfd=socket(AF_INET,SOCK_DGRAM,0); if(sockfd < 0) perror("\nsocket error\n"); bzero(&servaddr,sizeof(servaddr)); servaddr.sin_family=AF_INET; servaddr.sin_addr.s_addr=inet_addr(argv[1]); servaddr.sin_port=htons(5000); printf("STRING CONCATENATION"); printf("\nEnter the 1st string :"); gets(str1); len=sizeof(servaddr); sendto(sockfd,str1,sizeof(str1),0,(struct sockaddr*)&servaddr,len); printf("\nEnter the 2nd string :"); gets(str2); len=sizeof(servaddr); sendto(sockfd,str2,sizeof(str2),0,(struct sockaddr*)&servaddr,len); recvfrom(sockfd,buff,sizeof(buff),0,(struct sockaddr*)&servaddr,&len); printf("\nThe message echoed : %s\n\n",buff); close(sockfd);

return 0; }

Sign up to vote on this title
UsefulNot useful