<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Socket Client set timeout in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213891#M714404</link>
    <description>Hi friends. I have an application Client in HP10.20. How I can put a timeout(example 5 seconds) in the connect(socket, addr, addrlen) sentence for return after this 5 seconds if can not connect to server during this time. Right now the sentence returns after 75 seconds, and is to late for my application takes other actions.&lt;BR /&gt;Thanks a lot for your help.</description>
    <pubDate>Tue, 09 Mar 2004 16:04:24 GMT</pubDate>
    <dc:creator>Alfonso_15</dc:creator>
    <dc:date>2004-03-09T16:04:24Z</dc:date>
    <item>
      <title>Socket Client set timeout</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213891#M714404</link>
      <description>Hi friends. I have an application Client in HP10.20. How I can put a timeout(example 5 seconds) in the connect(socket, addr, addrlen) sentence for return after this 5 seconds if can not connect to server during this time. Right now the sentence returns after 75 seconds, and is to late for my application takes other actions.&lt;BR /&gt;Thanks a lot for your help.</description>
      <pubDate>Tue, 09 Mar 2004 16:04:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213891#M714404</guid>
      <dc:creator>Alfonso_15</dc:creator>
      <dc:date>2004-03-09T16:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Socket Client set timeout</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213892#M714405</link>
      <description>Not sure what language you are using here but generally, you want to set an "alarm" for 5 seconds before you do the "socket".  "Perl" has an "alarm" function for this.  If you trap "SIGALRM" you then have your timeour.</description>
      <pubDate>Wed, 10 Mar 2004 04:22:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213892#M714405</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-03-10T04:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Socket Client set timeout</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213893#M714406</link>
      <description>Hi. Thanks for the answer. I am using gcc. and the delay is in the sentence connect(socket, struct sock_addr, addrlen); This time out is not a property configurable for the socket? or maybe in the struct sock_addr? Thanks again.</description>
      <pubDate>Wed, 10 Mar 2004 10:11:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213893#M714406</guid>
      <dc:creator>Alfonso_15</dc:creator>
      <dc:date>2004-03-10T10:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: Socket Client set timeout</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213894#M714407</link>
      <description>I would guess that one of the ndd settings may be affecting your program's connect.  I don't know of a way to get connect to time out like you can a select().  It sounds like something in your network protocol is set to timeout after 75 seconds (and it could be two or more parms, such as a "retransmission interval" multiplied by a "number of retransmission attempts" before giving up).&lt;BR /&gt;You may want to use ndd -get to see your settings and may want to very cautiously modified a few.  You may want to call the HP RC for some advice on ndd as setting your timeout to 5 is going to affect more than just your program.</description>
      <pubDate>Thu, 11 Mar 2004 11:51:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213894#M714407</guid>
      <dc:creator>susan gregory_1</dc:creator>
      <dc:date>2004-03-11T11:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: Socket Client set timeout</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213895#M714408</link>
      <description>Alfonso,Here is my solution: TEST and RETEST at your own risk... :)#include &lt;SETJMP.H&gt;/* global */static jmp_buf env;void alarm_handler (int sig){    longjmp (env, 1);}... In your subroutine setup socket stuff..varsetc...    /*   Set up signal handler */    signal (SIGALRM, alarm_handler)  /* open up  a connection to the local server port */    if (setjmp (env) == 0) {        alarm (20);               /* 20 Second timeout */        if ((clnt = connect(socket, addr, addrlen) &amp;lt;0) {            alarm (0);            fprintf (stderr,                     "Could not open socket on Host (%s) on port(%s) \n",                     skthost, port);                                    return FAILURE;        }        alarm (0);    } else {        fprintf (stderr, "Timeout opening socket on Host (%s) on port(%s)\n",                 skthost, port);                        return FAILURE;    }Now for what is going on here... The signal handler "alarm_handler" returns a 1 to the setjum(env) call. Setjmp saves the stack context, it returns 0 when returned directly and a 1 when returned from longjmp.If the alarm is triggered (ie alarm(20) after 20 seconds... then the signal handler is executed and longjmp is called. The context is reset and a 1 is returned dropping you into the else section.Good luck... Ken&lt;/SETJMP.H&gt;</description>
      <pubDate>Thu, 18 Mar 2004 16:51:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/socket-client-set-timeout/m-p/3213895#M714408</guid>
      <dc:creator>Ken_109</dc:creator>
      <dc:date>2004-03-18T16:51:09Z</dc:date>
    </item>
  </channel>
</rss>

