network disconnecting [solved]

Hello,

is it possible to know if a client connection is lost?
However the client, when quit send a message to the server, it may that the client crashes… in this case, how to know, on the server side, that the connection to the client is down?

thanks

you mean socks communication? just try to send a message and if you get an exception the connection is obviously lost. (this only works with tcp not udp)

if its about crashing because of the exception, try:

try:
   the code which sometimes throws an exception
except:
   what to do if there is an exception

in case you’r using the queuedconnectionmanger. it has a resetConnectionAvailable() method. which works quite well for me.

Can you post a piece a code with this method? I don’t see how it works.

Thanks!

def _listenerPolling(self,tsk):
        """ poll for conections """
        if self.listener.newConnectionAvailable():        
            rendezvous = PointerToConnection()
            netAddress = NetAddress()
            newConnection = PointerToConnection()        
            if self.listener.getNewConnection(rendezvous,netAddress,newConnection):
                newConnection = newConnection.p()
                self.activeConnections[newConnection] = True # Remember connection
                self.reader.addConnection(newConnection) # Begin reading connection
        if self.manager.resetConnectionAvailable():
            connPointer = PointerToConnection()
            self.manager.getResetConnection(connPointer)
            connection = connPointer.p()                   
            if self.activeConnections.has_key(connection):
                del self.activeConnections[connection]
            self.manager.closeConnection(connection)
        return Task.cont

Thanks a lot