  Setting IP connect() timeout? 
 The Question is:
 
I have an application running in OpenVMS as client using socket connection
to a server NT application. My problem is connect() function in Open VMS
takes too long to timeout (about 2 min.) What can I do to change this
timeout to 5 seconds or so. I attempt
ed to use an AST to close socket with a sys$setimr() but somehow it screws
up the socket after that. Please advise me on this issue.
 
Thank you very much
 
 The Answer is:
 
  Something like the following (untested) program should be close -- the
  key here is use of the TCPIP$C_TCP_PROBE_IDLE in the setsockopt call.
 
 
#include &lt;socket.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;in.h&gt;
#include &lt;netdb.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;unixio.h&gt;
#include &lt;tcpip$inetdef.h&gt;
 
main(int argc, char *argv[]) {
   int s, i, len, five=5;
   struct sockaddr_in lcladdr, rmtaddr;
   char message[512];
   struct hostent *hp;
 
   if (argc != 2) {
      printf("Usage: %s &lt;hostname&gt;\n", argv[0]);
      exit(0);
   }
 
   if (!(hp = gethostbyname(argv[1]))) {
      printf("Unknown host: %s\n", argv[1]);
      exit(0);
   }
 
   lcladdr.sin_family = AF_INET;
   lcladdr.sin_addr.s_addr = INADDR_ANY;
   lcladdr.sin_port = htons(0);
 
   rmtaddr.sin_family = AF_INET;
   rmtaddr.sin_addr.s_addr = *(int *)hp-&gt;h_addr_list[0];
   rmtaddr.sin_port = htons(1234);
 
   if ((s = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0) perror("socket");
   if (bind(s, (void *) &amp;lcladdr, sizeof(lcladdr))) perror("bind");
   if (setsockopt(s, TCPIP$C_TCP, TCPIP$C_TCP_PROBE_IDLE, &amp;five, sizeof(five)))
      perror("setsockopt");
   if (connect(s, (void *) &amp;rmtaddr, sizeof(rmtaddr))) perror("connect");
   do {
      len = read(s, message, sizeof(message));
      if (len&gt;0) write(1, message, len);
   } while (len&gt;0);
   if (len&lt;0) perror("read");
   if (close(s)) perror("close");
   return EXIT_SUCCESS;
 
 
