Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


ofxTCPServer doesn't manage connected clients correcly #128

arturoc opened this Issue · 9 comments

6 participants


ofxTCPServer: fix for client disconnection. Closed by cb4ba37


Hey Arturo I think there is a problem with some of these changes; in particular:

bool ofxTCPServer::sendToAll(string message) {
if(TCPConnections.size() == 0) return false;

map<int,ofxTCPClient>::iterator it;
vector<int> disconnect;
for(it=TCPConnections.begin(); it!=TCPConnections.end(); it++){
    int err = 0;
    if(it->second.isConnected()) err = it->second.send(message);
    if(!TCPConnections[it->first].isConnected()) disconnect.push_back(it->first);
for(int i=0; i<(int)disconnect.size(); i++){
return true;


will disconnect a valid TCP connection...I haven't gone hunting in-depth, but I see that getNumClients returns TCPConnections.size()-1; so I'm assuming that [0] is the server? or reserved? somehow that scrambles the logic of how connections are being stored in the map...

For now I'm just commenting out the disconnection lines...I'm happy to pursue further but figure you'll see the problem faster ;-)


For now I'm doing:

if(!TCPConnections[it->first].isConnected() && it->first < TCPConnections.size()-1) disconnect.push_back(it->first);

but I don't really understand what ofxTCPClient is being stored in the map before I make a it the server itself that is being stored in the map first?


Was this issue fixed after all?
I'm having problems with getNumClients in connection with disconnectClient. Once a new client connects after disconnecting an old one, getNumClients increases by 2 and sendToAll results in an error.

@bilderbuchi bilderbuchi reopened this

As far as I can tell this is still an issue. SendToAll will disconnect a client.
gameoverhack's solution worked for me.


Pushing back issues without assignee to 0.8.1.

@arturoc arturoc was assigned

@arturoc - could you take another look at this, would be great to fix for 0.8 ?


i think i fixed it already in a later commit, but i need to check. will do it in a moment


i've tested with several clients and sendToAll and this seems to be fixed, indeed the line @gameoverhack points as the problem doesn't exist anymore.

@arturoc arturoc closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.