Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   catch non-blocking socket exceptions (http://www.velocityreviews.com/forums/t318881-catch-non-blocking-socket-exceptions.html)

Axel Bock 06-26-2003 03:03 PM

catch non-blocking socket exceptions
 
Hi all,

I try to connect to several hosts at once to verify whether a certain
service is running. Now it's quite stupid to connect to one after another,
cause if I do this I'll wait forever if some hosts don't respond (at least
until TCP timeout).

But if I connect to several hosts in parallel and use polling objects I'm
stuck - I don't know how to handle exceptions: are they raised as normal?
If yes, how do I get the correspondig socket object - or file number?
If no, how do I know if a socket timed out, or refused connection, or
something similar?


Thanks for any hints & greetings,

Axel.

Axel Bock 06-26-2003 03:07 PM

Re: catch non-blocking socket exceptions
 
Am Thu, 26 Jun 2003 17:03:11 +0200 schrieb Axel Bock:

> Hi all,
>
> I try to connect to several hosts at once to verify whether a certain
> [...blorf...]
>


or better still - does someone know how to set the tcp timeout value? THIS
would greatly simplyfy my task :-)


Thanks again & greetings (again),

Axel.


Peter Hansen 06-26-2003 03:17 PM

Re: catch non-blocking socket exceptions
 
Axel Bock wrote:
>
> I try to connect to several hosts at once to verify whether a certain
> service is running. Now it's quite stupid to connect to one after another,
> cause if I do this I'll wait forever if some hosts don't respond (at least
> until TCP timeout).
>
> But if I connect to several hosts in parallel and use polling objects I'm
> stuck - I don't know how to handle exceptions: are they raised as normal?
> If yes, how do I get the correspondig socket object - or file number?
> If no, how do I know if a socket timed out, or refused connection, or
> something similar?


Check out these pages for some background (especially page four on non-blocking
sockets):

http://www.mcmillan-inc.com/sock1.html

But consider just using Twisted and letting all this stuff be handled
for you... no sense reinventing the wheel in an area that is notoriously
difficult to do right.

-Peter

Axel Bock 06-26-2003 03:45 PM

Re: catch non-blocking socket exceptions
 
Am Thu, 26 Jun 2003 11:17:02 -0400 schrieb Peter Hansen:

> Check out these pages for some background (especially page four on
> non-blocking sockets):
>
> http://www.mcmillan-inc.com/sock1.html


great link :-) i forgot about select I admit ...

> But consider just using Twisted and letting all this stuff be handled
> for you... no sense reinventing the wheel in an area that is
> notoriously difficult to do right.


hm. twisted. yeah.
I tried it for the udp approach for the same problem, and ended up writing
the stuff by myself - the udp thing in twisted is rather ... twisted :-)
(and I do not consider the documentation/howtos/examples to be useful for
beginners in any way).

for tcp it might be worth a try ... although its really a quite simple
problem and twisted a rather large solution :-)


thanks,

axel.

Alan Kennedy 06-26-2003 04:45 PM

Re: catch non-blocking socket exceptions
 
Axel Bock wrote:

> hm. twisted. yeah.
> I tried it for the udp approach for the same problem, and ended up
> writing
> the stuff by myself - the udp thing in twisted is rather ... twisted :-)
> (and I do not consider the documentation/howtos/examples to be useful for
> beginners in any way).
>
> for tcp it might be worth a try ... although its really a quite simple
> problem and twisted a rather large solution :-)


Perhaps something like Spread is closer to what you need?

http://www.python.org/other/spread/

*Very* easy to get up and running, built for working with UDP, easy to configure
......

Just an alternative suggestion.

--
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan: http://xhaus.com/mailto/alan


All times are GMT. The time now is 10:22 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.