catch non-blocking socket exceptions

A

Axel Bock

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.
 
A

Axel Bock

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.
 
P

Peter Hansen

Axel said:
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
 
A

Axel Bock

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.
 
A

Alan Kennedy

Axel said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top