I have a situation here. I have a redundant TCP server setup which takes an input and then throws lots of packets forever. While reading them, I am also trying to keep up with the server’s state from TCP client by doing a send on the socket.
But my servers are redundant sharing a Virtual IP. So if server1 goes down, server2 starts up and uses the same VIP (At all point of time VIP is up and running). So my send technique is able to find out this situation.
My server2 waits for the client’s input, but since send is not doing the job I expect it to do, I am not able to send the input again.
int status = ::send ( m_sock, s.c_str(), s.size(), MSG_NOSIGNAL );
if ( status == -1 )
{
return false;
}
else
{
return true;
}
Can someone help how I can figure out this kind of failover?
Okay, piecing things together, I am starting to get a picture here.
The reason you’re not getting EPIPE from the send is that things happen this way:
senddata.sendunblocks and segments start travellingsendhas already returned. The connection is torn but there is no way to inform you of it (it doesn’t have any out-of-band mechanism)sendIn conclusion, if you want to test if a connection is still alive:
senddatasendagainIf you don’t get
EPIPEafter the secondsend, the connection is still up. Another scheme:senddata that should be interpreted as “Say something if you’re alive!”