brokenfoot
brokenfoot

Reputation: 11609

Difference in netinet/tcp.h Vs linux/tcp.h

I am trying to use the TCP option TCP_USER_TIMEOUT which was added to linux in 2.6.37.

Apprently my C source includes the netinet/tcp.h instead of linux/tcp.h. And TCP_USER_TIMEOUT is defined in linux/tcp.h and not in netinet/tcp.h I read here that user space apps should NOT include any header from linux/ (like in this case linux/tcp.h). But that link doesn't explain why.

Upvotes: 2

Views: 3091

Answers (1)

abligh
abligh

Reputation: 25119

Your source is incorrect, and a bulletin board is hardly a definitive source.

You should not include header files from the linux directory unless you are trying to include linux specific functions which are only to be found by including header files from the linux directory.

In relation to TCP_USER_TIMEOUT, the man-page for TCP notes in respect of many of the options 'This option should not be used in code intended to be portable'. Whilst it does not note this in respect of TCP_USER_TIMEOUT, it is a linux-only option as far as I understand it.

However, in this case:

$ grep -r TCP_USER_TIMEOUT /usr/include
/usr/include/netinet/tcp.h:#define TCP_USER_TIMEOUT  18 /* How long for loss retry before timeout */
/usr/include/linux/tcp.h:#define TCP_USER_TIMEOUT   18  /* How long for loss retry before timeout */

at least in my include files, it's present in both files. Perhaps you need to update your includes.

Upvotes: 3

Related Questions