Skip to content

Commit

Permalink
Bugfix ofx tcp manager (#6201)
Browse files Browse the repository at this point in the history
On Windows, when a TCP client disconnects from a TCP server and then reconnects, the ioctlsocket method still needs to be called. If it is not then blocking is automatically set to true.

To test:

    Change code to print out the frame rate of the networkTcpClientExample project.
    Run networkTcpServerExample app and networkTcpClientExample app.
    Quit networkTcpServerExample app
    Run networkTcpServerExample app again

You will notice the framerate of networkTcpClientExample drops to ~9fps. This is because the socket has been set with blocking = true and the server is sending messages every ~100ms.

If blocking is set as false then currently the SetNonBlocking method will return before ioctlsocket is called and the socket will be set with blocking on.
  • Loading branch information
chriship authored and arturoc committed Jan 4, 2019
1 parent fb0ec3c commit 0bf04a4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions addons/ofxNetwork/src/ofxTCPManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ int ofxTCPManager::WaitSend(time_t timeoutSeconds, time_t timeoutMicros){
//--------------------------------------------------------------------------------
bool ofxTCPManager::SetNonBlocking(bool useNonBlocking)
{
if(useNonBlocking==nonBlocking){
return true;
}
//if(useNonBlocking==nonBlocking){
//return true;
//}
auto prevNonBlocking = nonBlocking;
nonBlocking = useNonBlocking;

Expand Down

0 comments on commit 0bf04a4

Please sign in to comment.