#include<netinet/in.h> #include<string.

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

int sockfd,clifd; socklen_t len; char name[10], int sockfd,clifd; socklen_t len; int sockfd,clifd; socklen_t len; char name[10], int sockfd,clifd; char name[10], int sockfd,clifd; socklen_t len; char name[10], int sockfd,clifd; socklen_t len; char name[10], int sockfd,clifd; socklen_t len; char name[10],size[5]; char buf[100][200]; FILE*f1,*f2,*f3;int i=0,j; struct sockaddr_in servaddr,cliaddr;

sockfd=socket(AF_INET,SOCK_STREAM,0); if(sockfd<0) servaddr.sin_port=htons(5001); servaddr.sin_addr.s_addr=INADDR_ANY; bind(sockfd,(struct sockaddr*)&servaddr,sizeof(servaddr)); listen(sockfd,0); len=sizeof(struct sockaddr); clifd=accept(sockfd,(struct sockaddr*)&clifd,&len); read(clifd,name,sizeof(name)); f1=fopen(name,"r"); fgets(buf[i],200,f1); len=sizeof(struct sockaddr); clifd=accept(sockfd,(struct sockaddr*)&clifd,&len); read(clifd,name,sizeof(name)); f1=fopen(name,"r"); len=sizeof(struct sockaddr); clifd=accept(sockfd,(struct sockaddr*)&clifd,&len); read(clifd,name,sizeof(name)); f1=fopen(name,"r");

i++; while(!feof(f1)) { fgets(buf[i],200,f1); i++; } snprintf(size,sizeof(size),"%d",i);

//write(clifd,size,sizeof(size)); f2=fopen("c.txt","w"); for(j=0;j<i;j++) { fputs(buf[j],f2); } write(clifd,"c.txt",sizeof("c.txt")); fclose(f1); fclose(f2); f3=fopen("a.txt","r"); close(sockfd); return 0; }

Sign up to vote on this title
UsefulNot useful