title: How to set TCP keep alive interval for a specific socket fd (Not system wide) in VxWorks?
body: <p>I created a TCP socket in an application with KEEPALIVE enabled for this socket. I can see that keepalive packets are coming with the frequency of keepalive interval which i have already set in my system variable of iptcp, i.e 30secs.</p>
  
  <p>Socket Creation:</p>
  
  <pre><code>  if( ( sockFD = socket( AF_INET, SOCK_STREAM, 0 ) ) == ERROR )
    {
      DS_SWX_ERROR( "socket(%d,%d,%d) failed.", AF_INET, SOCK_STREAM, 0 );
      return;
    }
  
  </code></pre>
  
  <p>VxWorks TCP System Variables:</p>
  
  <pre><code>[vxWorks *]# sysvar list iptcp
  System variables:
     iptcp.KeepCnt=3
     iptcp.KeepIdle=60
     iptcp.KeepIntvl=30
  
  </code></pre>
  
  <p>As mentioned above according to system variables it is working fine. I am getting keep alive packets at the 30 seconds interval after 3 consecutive packets loss my connection get closed. Everything is working fine as system variables. But this TCP system variable configuration is same for all the sockets which have keep alive enabled. </p>
  
  <p><strong>I want to set this keep alive interval only for my socket created,  not for the complete system.</strong></p>
  
  <p>I already tried to set the keep alive interval using the setsockopt.</p>
  
  <pre><code> if( (setsockopt( sockFD, SOL_SOCKET, IP_TCP_KEEPINTVL,
        (char *)5, sizeof(int) )) == ERROR )
    {
      DS_SWX_ERROR( "setsockopt(%d,%d,%d,0x%x,%d) failed, Error is %d\n",
                    sockFD, SOL_SOCKET, SO_KEEPALIVE,
                    (char*) &amp;optVal, sizeof(optVal), errnum );
    }
  
  </code></pre>
  
  <p>and</p>
  
  <pre><code> if( (setsockopt( sockFD, IP_IPPROTO_IP, IP_TCP_KEEPINTVL,
        (char *)5, sizeof(int) )) == ERROR )
    {
      DS_SWX_ERROR( "setsockopt(%d,%d,%d,0x%x,%d) failed, Error is %d\n",
                    sockFD, SOL_SOCKET, SO_KEEPALIVE,
                    (char*) &amp;optVal, sizeof(optVal), errnum );
    }
  
  </code></pre>
  
  <p>both the above setsockopt is returning the same Error status which is Operation not supported. (45, IP_ERRNO_EOPNOTSUPP)</p>
  
  <p>Here i wanted to set the TCP KEEP ALIVE INTERVAL as 5 secs.</p>
  
  <p>I expect to set the tcp keep alive interval for a specific socket fd.</p>
  
  <p>Edited:
  This question is not the duplicate of <a href="https://stackoverflow.com/questions/4406906/how-to-set-keepalive-option-for-induvidual-socket-in-vxworks">How to set keepalive option for induvidual socket in VxWorks</a>
  That question does not have my answer. Please check. First answer is the same question i asked here, and in the second answer that link is not working.</p>