Appendix B. Networking API

Connecting to the Network

The Sockets API provides tools to help you create sockets and connect to other hosts. This section describes the API relevant to socket creation and connection.

socket()

socket() creates a bidirectional channel that typically connects with the network. You can use this channel with network-specific system calls or general file I/O.

Prototype

#include <resolv.h>
#include <sys/socket.h>
#include <sys/types.h>int socket(int domain, int type, int protocol);

Return Value

If successful, the ...

Get Linux® Socket Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.