OS is Redhat Linux.
The code failing:
Code:
void fail(void) {
if(!(client->isConnected)) {
fprintf(stderr,"Error, you are not connected to server\n");
return;
}
safeSend(client->serverSock, "test", strlen("test")+1, client);
safeSend(client->serverSock, "test", strlen("test")+1, client);
}
int safeSend(int incomingSocket, char *data, int size, struct ClientInfo *client) {
if(client->isConnected == 0) {
fprintf(stderr,"RETURN -1\n");
return -1;
}
int pos = 0;
ssize_t status = 0;
while(pos != size) {
fprintf(stderr, "SEND IN FUNC\n");
status = send(incomingSocket, &(data[pos]), size-pos, 0);
fprintf(stderr, "END SEND IN FUNC\n");
pos+=status;
if(status == -1) {
perror("send");
return status;
}
}
fprintf(stderr,"Return 0!\n");
return 0; // All is well
}
What happens if I try to run fail() with an allready closed connection, is this:
Code:
SAFESEND:
SEND IN FUNC
END SEND IN FUNC
Return 0!
SEND IN FUNC
And there it just stops. And by stop, I mean that the program terminates.