Heiko Wundram wrote:

Remember: connecting is also a non-blocking operation, if the socket is
set to non-blocking mode.
I should have read some more about sockets before trying to use
async_chat; I thought I would get by 'just adding a few methods'. Shame
on me ;-)

Anyway, what happened is that 'create_socket()' and 'connect()' were
called to quickly one after the other; as async_chat (asnycore,
actually) sets the socket on creation to non-blocking, my connect failed.

I solved the problem by adding a method 'connect()' in my derived class
which looks like this:

def connect(self,*args):

This did the trick for my chat client.
I dunno why async_chat doesn't work with this on Windows (on *nix, this
is exactly what it does), but I guess it has something to do with
decoding the error codes, as a *nix-socket would return EWOULDBLOCK in
this case, for which it checks, I am certain of that.
I think it works as designed, but it was not designed to open sockets
for clients, only for servers. I could have opened the socket outside
the method, probably, but I really wanted the class to handle all of the
network stuff.

Anyway, it works fine now.

Thanks for your explanation.


Real e-mail address is 'cHVAdm8ubHU=\n'.decode('base64')
Visit my Homepage at http://www.homepages.lu/pu/

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 6 | next ›
Discussion Overview
grouppython-list @
postedAug 17, '03 at 9:23p
activeAug 19, '03 at 8:41p



site design / logo © 2022 Grokbase