[Twisted-Python] Plain windows sockets and twisted

Daniel Griffin dgriff1 at gmail.com
Sun Jan 17 22:45:46 EST 2010


Here are two tiny apps. They run perfectly on OSX and error like this on
windows:

Log conenction  [Failure instance: Traceback (failure with no frames):
<class 't
wisted.internet.error.ConnectionLost' Connection to the other side was lost
in
 a non-clean fashion.
] Log conenction  [Failure instance: Traceback (failure with no frames):
<class
'twisted.internet.error.ConnectionLost' Connection to the other side was
lost
in a non-clean fashion.
....

Start server.py then run tclient.py.

Dan



On Sun, Jan 17, 2010 at 8:55 PM, Daniel Griffin <dgriff1 at gmail.com> wrote:

> Thank you for the response. I am using twisted 9.0 and tried 8.2. The
> python version is 2.6. When I print the reason sent to connection lost I get
> "[Failure instance: Traceback (failure with no frames): <class 't
> wisted.internet.error.ConnectionLost' Connection to the other side was lost
> in
>  a non-clean fashion.". I am using IP4 TCP sockets.
>
> I realize python threads are defective but in this case they are easier to
> deal with.
>
> I will create a chunk of sample code and send it to the list.
>
> Thanks,
> Dan
>
>
>
> On Sun, Jan 17, 2010 at 6:52 PM, Glyph Lefkowitz <glyph at twistedmatrix.com>wrote:
>
>>
>> On Jan 17, 2010, at 6:25 PM, Daniel Griffin wrote:
>>
>> > I am using twisted in a cross-platform manner. I have written both the
>> client and server. The client is twisted and the server uses python threads.
>> I am using the select reactor and plain old TCP connections. I encode my
>> messages to JSON to send them.
>> >
>> > On Windows I get tons of un-clean connectionlost events, on Mac
>> everything works perfectly. I am using the same data set in each case.
>>
>> You should use Twisted for your server and get rid of threads, or you
>> should very carefully read <
>> http://itamarst.org/writings/win32sockets.html> and understand the
>> differences between what windows calls "sockets" and what the rest of the
>> world does.
>>
>> > If I use the threaded server on windows and the twisted client on mac
>> then I still get tons of errors. 99% of these times these errors happen
>> after the last dataReceived when the socket should be closed cleanly.
>>  .
>>  .
>>  .
>> >
>> > Is this the correct behavior for using plain sockets with twisted? Any
>> reason why this would be perfectly fine on OSX and not Windows? Sorry for
>> the long email.
>>
>> You'll need to give some more detail.  What errors are you seeing?  Please
>> post a complete traceback, along with enough code to actually trigger the
>> error.  (<http://sscce.org/> is a good resource explaining desirable
>> attributes of such an example.)
>>
>> What version of Twisted are you using?  What version of Python?  What is
>> the protocol?  Are the errors occurring in your threaded server or your
>> twisted client?
>>
>> The quick answer to your question is: no, this behavior is not expected.
>>  Sockets are sockets.  Twisted should work fine talking to sockets in
>> threads, sockets in other programming languages, other operating systems,
>> etc.  Of course, that's just what's *supposed* to happen: there's a bug
>> here, and with the information I have now, I can't say whether it's in your
>> threaded code, your Twisted code, Twisted, or even Python.
>>
>> Good luck?
>>
>>
>>
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100117/8d7e08a7/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: server.py
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20100117/8d7e08a7/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tclient.py
Type: application/octet-stream
Size: 754 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20100117/8d7e08a7/attachment-0003.obj 


More information about the Twisted-Python mailing list