CITS3002 Computer Networks  
← prev
next → CITS3002 help3002 CITS3002 schedule  

Establishing Sockets With OS System Calls

The socket mechanism requires several Unix system calls. The socket() call establishes an end point of a communications link.

#include <sys/socket.h>

    int family, type, protocol;
    int sd, socket(int, int, int);
     ...
    sd = socket(addr_family, type, protocol);

protocol is usually 0 to indicate the default for the family/type combination. The socket() system call returns a small integer, termed a socket descriptor, (akin to a file descriptor). The call may fail due to a request for an unknown protocol or when a request is made for a type without a supporting protocol.

syscallorder

The socket() system call only instantiates protocol from the 5-tuple association.

Depending on whether the socket is being used in the client or server of either a connection-oriented or connectionless communication, different programs do different things next:


CITS3002 Computer Networks, Lecture 8, Transport layer protocols and APIs, p11, 24th April 2024.