asynchat question
Erik Max Francis
max at alcyone.com
Sat Aug 16 19:29:08 EDT 2003
Patrick Useldinger wrote:
> The client connects and send his question. The server answers, but the
> client never receives an answer. On the server side, I receive the
> following message:
>
> error: uncaptured python exception, closing channel
> __main__.SecondaryServer connected 127.0.0.1:3432 at 0x7fc968>
> (socket.error:(10053, 'Software caused connection abort')
> C:\Python23\lib\asynchat.py|handle_read|88] [C:\Python23\lib\asyn
> core.py|recv|353])
>
> Can anyone explain why?
There are several problems here. For starters, your server class isn't
really a server, since it doesn't derive from asyncore.dispatcher, and
doesn't bind to a port, so connections never come in. (And you wanted
to override handle_accept, not handle_connect.) Try something like this
for your server:
class Server(asyncore.dispatcher):
def __init__(self, port, isQuiet=False):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
self.addr = '', port
self.bind(self.addr)
self.listen(5)
def handle_accept(self):
Connection(self, self.accept())
where Connection is a class that derives from asynchat.async_chat.
I'm sure a dozen people will tell you to use Twisted, now.
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Who's not sat tense before his own heart's curtain?
\__/ Rainer Maria Rilke
More information about the Python-list
mailing list