Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an application that I'm testing/debugging I would like to know if the connections that it's opening have had the TCP_NODELAY set. Is there are a way to do this e.g. using netstat to look at the details of an open connection? Is something like strace or system tap my best option?

share|improve this question
    
I'd use tcpdump –  Eric DANNIELOU Jan 24 '13 at 8:25
    
AFAIK tcpdump only captures the data. TCP_NODELAY is a connection option that you set on your code, not an option that you can find on the packets being sent. –  drcelus Jan 24 '13 at 8:27
add comment

1 Answer

up vote 2 down vote accepted

Sadly you can't after the socket has already been opened. The information linux kernel hands out lacks this information.

See http://lkml.indiana.edu/hypermail/linux/kernel/0409.1/2166.html

You can trace your code via strace and look for lines similar to this (taken from stracing mysql client connecting to a mysql server)

socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
fcntl(3, F_SETFL, O_RDONLY)             = 0
fcntl(3, F_GETFL)                       = 0x2 (flags O_RDWR)
connect(3, {sa_family=AF_INET, sin_port=htons(9000), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
setsockopt(3, SOL_SOCKET, SO_RCVTIMEO, "\2003\341\1\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
setsockopt(3, SOL_SOCKET, SO_SNDTIMEO, "\2003\341\1\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
setsockopt(3, SOL_IP, IP_TOS, [8], 4)   = 0
setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0
setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0

If you're on a BSD or non-linux unixy system

lsof -a -p PID -i 4 -T f

could work ( See this http://stackoverflow.com/questions/1824115/display-socket-options similar question ).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.