× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Scott and Patrick,

Thanks so much for pointing me in the right direction.


I have other socket programs (direct print) that I will look at too.


Thanks again,


Craig



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Scott Klement
Sent: Friday, October 24, 2008 6:36 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Test device before connect()

Craig Jacobsen wrote:
When it drops, the connect() hangs for 3 to 5 minutes trying to make a
connection.
(I would like that to be a few seconds, but there are no time out values
that I can see.)

Here's an article that I wrote about timeouts with sockets. It
describes two ways to do a timeout, and has sample code for the connect API:
http://systeminetwork.com/article/timeouts-sockets-0


Further, I would add that if you want to write robust TCP apps -- ones
that can survive a network that's having trouble -- then you need to be
using non-blocking sockets throughout your application.

Non-blocking assures that your application can NEVER get stuck forever
waiting for the network. And in a robust application, that's a very
important thing to do.

You were lucky in your instance -- you got stuck on the connect() API,
which is relatively kind in that it times out after a number of minutes.
Had you had the network error during a send() or recv() API, you
might've gotten hung up permanently with no timeouts at all.

Use non-blocking with select() for everything you do. Write yourself a
library of socket routines and put them in a service program and have
them do all of the work for you, including the non-blocking and select()
code.

In THAT environment, you'll never get hung up permanently, and you'll
have complete control over how long you wait for a time out.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.