error with TCP_KEEPCNT , TCP_KEEPIDLE , TCP_KEEPINTVL undeclared identifier UBunto 16.04 -- Linux 4.15.0-

时间:2019-04-27 12:24:43

标签: c linux sockets networking

I'm having some issue with setsocketopt() function. I'm trying to set the keep alive interval and idle time. I got a problem with undeclared identifier : TCP_KEEPCNT TCP_KEEPIDLE TCP_KEEPINTVL however when I'm using SO_KEEPALIVE it's defined. am I missing some header file or is there a way to specify idle time and interval time using SO_KEEPALIVE

 //my headers : 
 #include <sys/types.h>          /* See NOTES */
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 //#include <logging/Trace.h>
 #include "socket.h"
 #include <arpa/inet.h>
 .
 .
 .
 ...


 if(setsockopt(_socket, IPPROTO_TCP, TCP_KEEPIDLE, &keepidle, sizeof(int)))
     {
             perror("setting keep alive idle count failed");
             return -1;
     }

0 个答案:

没有答案