title: How to set a timeout in connect/send ? ( as400 iseries v5r4, rpg )
body: <p>From this <a href="http://www.scottklement.com/rpg/socktut/tutorial.html" rel="nofollow noreferrer">rpg socket tutorial</a> we created a socket client in rpg that calls a java server socket </p>
  
  <p>The problem is that connect()/send() operations blocks and we have a requirement that if the connect/send couldn't be done in a matter of a second per say, we have to just log it and finish.</p>
  
  <p>If I set the socket to non-blocking mode (I think with fnctl), we are not fully understanding how to proceed, and can't find any useful documentation with examples for it.</p>
  
  <p>I think if I do connect to a non-blocking socket I have to do select(..., timeout) which tells us if the connect succeed and/ we are able to send(bytes). But, if we send(bytes) afterwards, as it is now a non-blocking socket (which will immediately return after the call), how do I know that send() did the actual sending of the bytes to the server before closing the socket ?</p>
  
  <p>I can fall back to have the client socket in AS400 as a Java or C procedure, but I really want to just keep it in a simple RPG program.</p>
  
  <p>Would somebody help me understand how to do that please ? 
  Thanks !</p>