I am having some trouble with this code. The problem is when i Request the Server to send me some data and the client just Disconnects when the server tries to send me data, the application Exists.
Here’s the lines I think cause the problem
int SendBinary(int *byte, int length) { int bytes_sent; bytes_sent = send(connecting_socket, byte, length, 0); return bytes_sent; return 0; } void SendFile(FILE *fp, int file_size) { int current_char = 0; do{ current_char = fgetc(fp); if ( current_char == EOF ) break; SendBinary(¤t_char, sizeof(char)); } while(current_char != EOF); }
Any ideas what i should do to prevent this? Revise the whole source for complements to this snippet.
Perhaps your application is receiving SIGPIPE during the write/send and not ignoring it? Try ignoring this signal or installing a do-nothing handler for it.