The socket APIs provide many functions for use in network programming. Here are the common socket functions that we use in this book:
- socket() creates and initializes a new socket.
- bind() associates a socket with a particular local IP address and port number.
- listen() is used on the server to cause a TCP socket to listen for new connections.
- connect() is used on the client to set the remote address and port. In the case of TCP, it also establishes a connection.
- accept() is used on the server to create a new socket for an incoming TCP connection.
- send() and recv() are used to send and receive data with a socket.
- sendto() and recvfrom() are used to send and receive data from sockets without a bound remote address.
- close() (Berkeley sockets) and closesocket() (Winsock sockets) are used to close a socket. In the case of TCP, this also terminates the connection.
- shutdown...