[medusa] EINPROGRESS
Sam Rushing
rushing@n...
Thu, 20 Jul 2000 10:42:09 -0700 (PDT)
yp66@h... writes:
> I am making a client/server application on Linux Redhat 6.1 Python
> 5.2 (default redhat distro).
> Both the client and server are using asynchat.py
> When I use the (default setting) non-blocking client socket, a
> EINPROGRESS exception occurs in the connect method, self.connected
> will not be set to 1 and therefore the flush() method will not do
> anything
> (if I set self.connected=1 by hand afterwards, my application works
> like a charm)
>
> (on NT it will give a EWOULDBLOCK)
It looks like you're relying on the connect() succeeding immediately?
Which isn't always going to be the case. [on a really fast local
network it can actually succeed before the call to connect() returns,
but this is certainly luck]
What asyncore will do is this: as soon as it sees a 'WRITE' event on
that socket, it will set 'connected=1', and will call the
'handle_connect' method. This is where you will want to place the
code that would normally come directly after a blocking call to
connect().
> Is there a simple example for a client/server implemented with
> asynchat at both sides (simpler than the proxy-example) or an
> explanation for my little problem.
A quick scan over the medusa sources shows rpc_client and rpc_server,
if you ignore all the RPC stuff and pay attention to the
asynchat-based classes, these are pretty vanilla examples.
-Sam