Q
Problem solve Get help with specific problems with your technologies, process and projects.

Controlling time out for a socket connection

How can I control the timeout for a socket connection? My sockets functions are written in C in a service program. I have tried using signal and alarm, but they kill the AS/400 job without returning control to the socket program.
My assumption is that you are referring to a block receive operation, that is you are trying to receive something from the partner program, but nothing is received and your program waits forever.

In my opinion the most flexible socket option to control your program is using the select API, which allows you to wait for the socket and specify a timeout (you can also issue a non-blocked receive, but it is, in my opinion, the wrong approach).

This page describes the select API very well. It discuss mainly the server, but you can also use it on your client with no problem.

This was last published in June 2005

Dig Deeper on Physical connections to iSeries

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close