Content deleted Content added
mNo edit summary |
content copied from Internet_socket#Implementation_issues |
||
Line 2:
A program that can act both as a client and a server is based on [[peer-to-peer]] communication.
Sockets are usually implemented by an [[Application programming interface|API]] library such as [[Berkeley sockets]], first introduced in 1983. Most implementations are based on [[Berkeley sockets]], for example [[Winsock]] introduced 1991. Other socket API implementations exist, such as the [[Streams (networking API)|STREAMS]]-based [[Transport Layer Interface]] (TLI).
These are examples of functions or methods typically provided by the API library:
* <code>socket()</code> creates a new socket of a certain socket type, identified by an integer number, and allocates system resources to it.
* <code>bind()</code> is typically used on the server side, and associates a socket with a socket address structure, i.e. a specified local port number and IP address.
* <code>listen()</code> is used on the server side, and causes a bound TCP socket to enter listening state.
* <code>connect()</code> is used on the client side, and assigns a free local port number to a socket. In case of a TCP socket, it causes an attempt to establish a new TCP connection.
* <code>accept()</code> is used on the server side. It accepts a received incoming attempt to create a new TCP connection from the remote client, and creates a new socket associated with the socket address pair of this connection.
* <code>send()</code> and <code>recv()</code>, or <code>write()</code> and <code>read()</code>, or <code>recvfrom()</code> and <code>sendto()</code>, are used for sending and receiving data to/from a remote socket.
* <code>close()</code> causes the system to release resources allocated to a socket. In case of TCP, the connection is terminated.
== See also ==
|