Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > catch non-blocking socket exceptions

Reply
Thread Tools

catch non-blocking socket exceptions

 
 
Axel Bock
Guest
Posts: n/a
 
      06-26-2003
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.
 
Reply With Quote
 
 
 
 
Axel Bock
Guest
Posts: n/a
 
      06-26-2003
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.

 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      06-26-2003
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
 
Reply With Quote
 
Axel Bock
Guest
Posts: n/a
 
      06-26-2003
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.
 
Reply With Quote
 
Alan Kennedy
Guest
Posts: n/a
 
      06-26-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 1 02-03-2009 06:20 AM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 0 02-01-2009 12:45 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57