#include <linux/net.h> /* Definition of SYS_* constants */ #include <sys/syscall.h> /* Definition of SYS_socketcall */ #include <unistd.h> int syscall(SYS_socketcall, int call, unsigned long *args);
Note: glibc provides no wrapper for socketcall(), necessitating the use of syscall(2).
User programs should call the appropriate functions by their usual names. Only standard library implementors and kernel hackers need to know about socketcall().
call | Man page |
SYS_SOCKET |
socket(2)
|
SYS_BIND |
bind(2)
|
SYS_CONNECT |
connect(2)
|
SYS_LISTEN |
listen(2)
|
SYS_ACCEPT |
accept(2)
|
SYS_GETSOCKNAME |
getsockname(2)
|
SYS_GETPEERNAME |
getpeername(2)
|
SYS_SOCKETPAIR |
socketpair(2)
|
SYS_SEND |
send(2)
|
SYS_RECV |
recv(2)
|
SYS_SENDTO |
sendto(2)
|
SYS_RECVFROM |
recvfrom(2)
|
SYS_SHUTDOWN |
shutdown(2)
|
SYS_SETSOCKOPT |
setsockopt(2)
|
SYS_GETSOCKOPT |
getsockopt(2)
|
SYS_SENDMSG |
sendmsg(2)
|
SYS_RECVMSG |
recvmsg(2)
|
SYS_ACCEPT4 |
accept4(2)
|
SYS_RECVMMSG |
recvmmsg(2)
|
SYS_SENDMMSG |
sendmmsg(2)
|
On x86-32, socketcall() was historically the only entry point for the sockets API. However, starting in Linux 4.3, direct system calls are provided on x86-32 for the sockets API. This facilitates the creation of seccomp(2) filters that filter sockets system calls (for new user-space binaries that are compiled to use the new entry points) and also provides a (very) small performance improvement.