Expert Answer Center > Experts On Demand > View Answer
EMAIL THIS
Experts on Demand
  EXPERTS ON DEMAND HOME     POSE A QUESTION     VIEW ANSWERS     BROWSE BY TOPIC        RSS FEEDS  
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. QUESTION POSED ON: 02 JUN 2005
QUESTION ANSWERED BY: Shahar Mor 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.

HomeExperts on DemandIT Expert Webcast SeriesExpert KnowledgebaseSite Index
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts