Skip to content
Advertisement

Get struct socket*, struct sock * from socket descriptor in a C program on Linux

I’m working on a C program on Linux (unprivileged).

Is it possible to get a reference to struct socket or struct sock from the socket descriptor?

Thank you.

Advertisement

Answer

If you’re working in user mode (eg. not kernel mode), you cannot directly manipulate kernel structures (including struct sock). If you do need access to these kernel structures, you will need to write code running in kernel mode (likely in a kernel module).

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement