Reputation: 31
When reading C source code, I see the socket
function used to open a connection. When I search for the definition of socket
in the Linux kernel source code (version 3 and above) using grep
, I can find more calls to socket
but not the definition.
Where is socket
defined? Is it defined in the source code of the ethernet card?
Upvotes: 0
Views: 942
Reputation: 1783
I realize this thread is ancient, but I actually had to go look this up because I'm working on a security stack that does 10Gb/s and needed to know how this was implemented. I was able to find the source here: https://github.com/torvalds/linux/blob/master/net/socket.c
Upvotes: 0
Reputation: 19
The socket()
function is not a kernel function, it is a libc
one.
If you want to study socket()
internals get the code of the glibc
(or any implementation of the standard C library), not the kernel code.
If you plan to go even deeper than that and study how the kernel implements the sockets mechanism look for the system call sys_socketcall()
.
Upvotes: 2