socket-proramming

Is there easy way to do macro to string map?

For example,in Windows,if I want to make the error message of gethostbyname meaningful,I would need to manually map the error code to message, as follows, #include <stdio.h> #include <winsock2.h> #pragma comment(lib, "ws2_32.lib") int main(void) { struct hostent *host; WSAData wsaData; int errcode; if (WSAStartup(MAKEWORD(2, 2), &...

Blocking recv call hangs if server is down

Another socket problem. In my client code, I am sending some packet and expectign some response from the server side: send() recv() <-- it is blocking Immediately after send(), the server crashes and rebooted itself. In the meantime the recv() is waiting. But even after the server is up, the receive call is hanging. I have ad...