Get Socket details from user space

Submitted by kskkumar
on August 16, 2005 - 7:23am

Hi, i am using 2.6v of kernel. I am interested in getting the socket details of a TCP connection. This i have to do inthe userspace without altering the kernel. Is there any system call for the same? I recently came across 'netlink' system call which is available for both user space and kernel space. If possible, can i have a simple code of how to get the TCP connection state from the kernel? Any online links U suggest for my area of interest? Expecting Ur reply thank U.

getsockopt

on
August 16, 2005 - 9:18am

According to tcp(7) (a very interesting man-page, together with ip(7)), one of the option level arguments of getsockupt() is:

TCP_INFO
Used to collect information about this socket. The kernel returns a struct tcp_info as defined in the file /usr/include/linux/tcp.h. This option should not be used in code intended to be portable.

Looking at the mentioned struct tcp_info, it seems to be full of interesting information. Is this, what you want?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.