2

I need to find the socket options set for a File descriptor.

For example, the accept call returns a FD. I set a number of socket options. Then I need to find if the socket options are actually set for the FD.

P.S: setsockopt is not returning an error, but behavior of fd is not in line with the option. Hence I need to verify this.

ankit409
  • 93
  • 7

1 Answers1

0

You can simply call getsockopt().

mvp
  • 111,019
  • 13
  • 122
  • 148
  • Yes, but the application is running at the customer end so its not the easiest of things to do. Is it possible to use lsof or netstat to do the same – ankit409 Jun 16 '13 at 15:14
  • Socket descriptor number as returned by `accept`, only makes sense within your application process. Another app (like lsof or netstat) would not know what that number even means. So, you must do this during lifetime of that descriptor, that is inside your app. Thus, `getsockopt` is the only way. – mvp Jun 16 '13 at 19:42