Reputation: 36287
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.
Upvotes: 1
Views: 206
Reputation: 34948
Are you sure client didn't fail on receiving the data from server?
telnet
to your server to see
what it sends in response
Replace your server with
netcat
to make sure client is
behaving correctly
Sniff the traffic between server and
client using tcpdump
or similar
tool
Upvotes: 0
Reputation: 36429
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.
Upvotes: 6