Search Results

Search found 1 results on 1 pages for 'n r s sowrabh'.

Page 1/1 | 1 

  • Pthread-ed filetransfer application crash

    - by N.R.S.Sowrabh
    I am developing a file transfer application and am using pthreads on the receiver side for receiving multiple files. The function which is passed to pthreads calls the following function and at the end of this function I get a SIGABRT error and stack-smashing error appears on the terminal. Please help me find the bugs. If you need anymore code I'd be able to post the same. Thanks in advance. void recv_mesg(int new_sockid, char *fname) { cout<<"New Thread created with "<<new_sockid<<" and "<<fname<<endl; char buf[MAXLINE]; int fd; fd = open(fname, O_WRONLY ); int len =0; while (len<1024) { int curr = recv(new_sockid, buf, 1024-len, 0); //fprintf(stdout,"Message from Client:\n"); len += curr; //write (fd, buf, curr); fputs(buf, stderr); } int file_size = 0; sscanf(buf,"%d",&file_size); if(file_size<=0) perror("File Size < 0"); sprintf(buf,"Yes"); send(new_sockid,buf,strlen(buf),0); len = 0; while (len<file_size) { int curr = recv(new_sockid, buf, min(file_size-len,MAXLINE), 0); len += curr; write (fd, buf, curr); //fputs(buf, stdout); //fflush(stdout); } len = 0; close(fd); close(new_sockid); }

    Read the article

1