I am trying to connect two machines, say, machines A and B. I am trying to send a TCP message from A to B (one way). In a normal scenario, this works fine. When the connection is smooth, if the socket in B is closed, send () from A is stuck forever. And that puts the process in a Zombie state. I have a socket in locked mode in machine A. Below is the code that stuck forever.
if (send (txSock,&txSockbuf,sizeof(sockstruct),0) == -1) { printf ("Error in sending the socket Data\n"); } else { printf ("The SENT String is %s \n",sock_buf); }
How do I know if another socket is closed? What sends a return if the target socket is closed? Will the choice be useful.
source share