I’m connecting to a server in my C application using a socket connection. Once in a while the server just wont return anything. I mean NOTHING. So my application hangs. I’ve tried using a timeout:
signal(SIGALRM, timeouthandler);
alarm(myTimeout);
(socket and connection logic)...
alarm(0);
but it still hangs and doesn’t return to the script. A co-worker said it might be because I’m using a blocking connect. But from what I’m reading you set a connection to non-blocking after the connection is already made.
What should I look into?
‘What should I look into?’
As a debugging tool, I find Wireshark is useful when debugging socket connections. I’ve done a few socket applications in C, and sometimes it comes down to the TCP stack library doing wonky things, and Wireshark can sometimes uncover that.
Hope this helps,