Hi everyone,<br><br>I am running a server in application context via:<br><br># code: server.tac<br>factory = Factory()<br>factory.protocol = MyProtocol<br>application = service.Application(&quot;MyServer&quot;)<br>service = internet.TCPServer(5555, factory)<br>
service.setServiceParent(application)<br># end code<br><br>ran with<br><br>$ twistd -ny server.tac<br><br>Here is some of my Protocol code:<br><br># code: myprotocol.py<br>def checkIdle(transport):<br>    while 1:<br>        now = time.time()<br>
        if now - transport.activityFlag &gt; 30.0:<br>            transport.loseConnection()<br>            time.sleep(1)<br>            break<br>            return<br>        time.sleep(8)<br>    return<br><br>class MyProtocol(Protocol):<br>
    def connectionMade(self):<br>        self.transport.activityFlag = time.time()<br>        thread.start_new_thread(checkIdle, (self.transport,))<br><br>    # ... the rest of the methods... not important for this question<br>
# end code<br><br>Now here&#39;s my problem: I want to kill connections from the server that have been idle for, say, 30 seconds. An idle connection is one in which is a _valid_ connection (i.e., it hasn&#39;t disconnected from the server) but hasn&#39;t sent any data for 30 seconds. The way I have initially set it up was in a thread. I simply check the last time it had activity from that particular transport. The really real problem I am having is when the connection is closed, the client doesn&#39;t know about it. It is simply closed on the server and the client is left hanging. If I test this in telnet with:<br>
<br>$ telnet localhost 5555<br><br>telnet never quits with a message: Connection closed by foreign host. (which is indeed exactly what I want)<br>The only way I get this response is if I try to send data to the server while the connection has been &quot;lost&quot;.<br>
<br>Can anyone direct me on the proper way to kill a connection from the server end in a clean manner?<br><br>(By the way, I&#39;m very new to twisted, not so new to Python).<br><br>Thanks for any help!<br clear="all"><br>
-- <br>Jonathan Sawyer<br>Geographic Information Network of Alaska (GINA)<br>University of Alaska Fairbanks<br>(907) 474-5689<br>