473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.
Jul 18 '05 #1
4 3913
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.

Jul 18 '05 #2
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
Jul 18 '05 #3
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.
Jul 18 '05 #4
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
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Steven T. Hatton | last post by:
If I understand correctly, I have no assurance that I can determine the type of a simple class instance thrown as an exception unless I explicitly catch it by name. (non-derived classes having no...
11
by: kaeli | last post by:
Hey all, I'd like to start using the try/catch construct in some scripts. Older browsers don't support this. What's the best way to test for support for this construct so it doesn't kill...
12
by: Andrew Schepler | last post by:
When compiled with Visual C++ .NET 2003 (only), the program below aborts as though no matching catch clause is present. If the copy constructor of A is made public, it successfully catches the...
18
by: Simon | last post by:
I was of the impression that code placed after a Try...Catch block was only executed if there was no exception thrown. I've got some VB.net code as part of a Windows form that executes even...
5
by: PasalicZaharije | last post by:
Hallo, few days ago I see ctor like this: Ctor() try : v1(0) { // some code } catch(...) { // some code }
7
by: Mr Flibble | last post by:
Are try { //something } catch { // }
5
by: not_a_commie | last post by:
Using a synchronized Queue, I did some testing on catching the "queue was empty on dequeue" exception vs. doing my own lock, checking for empty, and then dequeuing. The try/catch method, though...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
5
by: stevewilliams2004 | last post by:
I was wondering if someone could explain the output I am getting for the program below. What I expected from the main program output was "Cat" but instead I see "Mammal". The output is also...
4
by: Harukoten | last post by:
Hello everyone, this is my first time posting, so play nice >.> I have a loop with a try-catch statement in it that is giving me issues., here is the code for it: do {...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.