Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to implementation connect function on C

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading