I wanted to implement the connect function in C. And to be honest, I don’t know how to do it.
I looked at the sources (sys/socket.h) but I only saw a prototype of the connect function there. I also didn’t find anything on google.
>Solution :
Being connect
a system call, you should find its source code not in libc
but in the kernel code. For Linux, I believe this is the starting point, in socket.c
source file:
SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
int, addrlen)
{
return __sys_connect(fd, uservaddr, addrlen);
}