twisted .loseConnection does not immediately lose connection?

Posted by Claudiu on Stack Overflow See other posts from Stack Overflow or by Claudiu
Published on 2010-12-27T20:51:56Z Indexed on 2010/12/27 20:53 UTC
Read the original article Hit count: 140

I have a server with a few clients connected to it. When CTRL+C is hit (that is, reactor starts shutting down), I want to close all my connections, wait until they are cleanly closed, and then stop. I do this by going through the connected clients' transports and calling .loseConnection(). On the ones that are connected locally, they immediately disconnect. However, on one that is connected through the internet, the connection is not immediately lost. Communication stops - and closing the client program no longer even tells the server that the connection has died, although it does before calling .loseConnection() - but the connection is not deemed 'lost' until a few minutes later after I send a few heartbeat requests from the server.

I understand that if a connection dies, there's no way for the server to know unless it tries to send some data. But if I specifically ask for a connection to be closed, why does it not just close/disconnect immediately? Am I calling the wrong function?

© Stack Overflow or respective owner

Related posts about networking

Related posts about tcp