[c] How to find the socket connection state in C?