Skip to content

Instantly share code, notes, and snippets.

@Rolias
Created September 9, 2010 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rolias/677e6e83e154a2d60640 to your computer and use it in GitHub Desktop.
Save Rolias/677e6e83e154a2d60640 to your computer and use it in GitHub Desktop.
//This is a private Gist. The term private can be misleading. It just means it isn't available for public searching. Anyone
//that has the URL for this gist can read it. Here's an example of a code paset from Eclipse. I put ".cpp" on the title of
//of this Gist so that Gist knows it is c++ code and will do some formatting.
void TcpServer::ConnectAndProcess()
{
DebugUtil::Write("In TcpServer::ConnectAndProcess() ");
if (IsShutdownRequested())
{
cout << "TcpServer::ConnectAndProcess() shutdown has been requested."<< endl;
}
while (!IsShutdownRequested() && ListenSocketIsValid())
{
const bool connected = WaitForConnection();
if (connected)
{
_keepAlive.SetConnection(_tcpConnection);
_keepAlive.Enabled(KeepAliveEnabled());
OSTimeDly(1);// give any process launching us a chance to pend on mailbox
ProcessMessagesWhileConnectionOpen();
DebugUtil::Write("Connection Ended");
CloseConnection();
}
else
{
DebugUtil::Write("Connection not made within timeout period.");
}
}
string msg = "Exiting TcpServer::ConnectAndProcess() either shutdown requested or listen socket is not valid";
DebugUtil::Write(msg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment