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).