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()
andrecv()
are used to send and receive data with a socket.sendto()
andrecvfrom()
are used to send and receive data from sockets without a bound remote address.close()
(Berkeley sockets) andclosesocket()
(Winsock sockets) are used to close a socket. In the case of TCP, this also terminates the connection.shutdown()
is used to close one side of a TCP connection. It is useful to ensure an orderly connection teardown.select()
is used...