[Twisted-Python] Porting Apache Mina to Twisted

Godson Gera godson.g at gmail.com
Mon Dec 6 08:16:34 MST 2010

On Mon, Dec 6, 2010 at 7:41 PM, Umut Aydin <devnetwork at gmail.com> wrote:

> Hello again
> I couldn't get any answer to my question and I think I couldn't point
> my problem clearly.
> https://github.com/naimon/Jobbar/blob/master/src/lib/server.py
> On the line #130 I need to check if the socket is still connected.
> That worker variable is a copy of self.transport actually. I have
> found it's an instance of twisted.internet.tcp.Server
> I also found getHandle method to reach the actual socket but I
> couldn't find any method to check its availability.

Store a reference to the protocol object it self instead of protcol's

Connectiong checking  can be done easily by simply adding a state attribute
to your protocol class. In your protocol define self.isConnected = False .
Set that attribute to True inside connectionMade() event method and set that
to False inside connectionLost() event.

Thanks & Regards,
Godson Gera.
Twisted Python Consultant
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20101206/0f7e0cb3/attachment-0001.html>

More information about the Twisted-Python mailing list