Re: What system call will tell me the state of a socket's tcp connection?

Andi Kleen (ak@muc.de)
18 Jun 1999 02:12:47 +0200


In article <m3lndituz0.fsf@knave.bfnet.com>,
dave@bfnet.com writes:
> I have a socket's file descriptor:
> fd = accept (fd, sa, salenptr);

> and I want to know about its TCP state, as in the netstat (or cat
> /proc/net/tcp) output:

> Proto Recv-Q Send-Q Local Address Foreign Address State User Inode Timer
> tcp 15876 0 x.y.com:nntp z.x.com:63700 CLOSE_WAIT root 2754272 off (0.00/0/0)

> What system call do I use on the socket's file descriptor "fd" to
> discover the following:

> 1. State
> 2. Inode
> 3. Timer

> etc?

None. You have to parse /proc/net/tcp (readlink("/proc/self/<fd>") to find
the inode number)

-Andi

-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.rutgers.edu