Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ofxTCPServer doesn't manage connected clients correcly #128

Closed
arturoc opened this Issue · 9 comments

6 participants

@arturoc
Owner

ofxTCPServer: fix for client disconnection. Closed by cb4ba37

@gameoverhack
Collaborator

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++){
    TCPConnections.erase(disconnect[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 ;-)

@gameoverhack
Collaborator

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 connection...is it the server itself that is being stored in the map first?

@santa41116

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
@Drosen

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

@bilderbuchi
Owner

Pushing back issues without assignee to 0.8.1.

@arturoc arturoc was assigned
@ofTheo
Owner

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

@arturoc
Owner

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

@arturoc
Owner

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.