Where is connect?

Giorgos Keramidas keramida at ceid.upatras.gr
Tue Feb 26 03:48:19 UTC 2008


On 2008-02-25 21:23, a arcadia <aora57 at gmail.com> wrote:
> This is likely a silly question but where exactly is the source for
> connect?  Under /usr/src/lib/libc/sys there is connect.2 but  no
> connect.c, or any other socket functions for that matter.

It is a system call.  The userlevel part of system calls is,
traditionally, only a very thin wrapper around their kernel
counterparts.

If you look at `/usr/src/sys/kern/syscalls.master' you can see a line
which maps the connect(2) system call to the connect() kernel function:

% 98      AUE_CONNECT     STD     { int connect(int s, caddr_t name, \
%                                     int namelen); }

The connect() function itself is easy to locate in src/sys/kern:

% keramida at kobe:/usr/src/sys/kern$ grep -n '^connect' *.c
% uipc_syscalls.c:501:connect(td, uap)
% keramida at kobe:/usr/src/sys/kern$

This is the entry point of the connect(2) system call.  Things go on
from this point into the network stack & protocol support code.



More information about the freebsd-questions mailing list