what is socket

1 year ago 34
Nature

A socket is a software structure within a network node of a computer network that serves as an endpoint for sending and receiving data across the network. It is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to. Sockets are created only during the lifetime of a process of an application running in the node. In the Berkeley sockets standard, sockets are a form of file descriptor, due to the Unix philosophy that "everything is a file", and the analogies between sockets and files. Sockets allow communication between two different processes on the same or different machines using standard Unix file descriptors. To a programmer, a socket looks and behaves much like a low-level file descriptor, and commands such as read() and write() work with sockets in the same way they do with files and pipes. Socket is primarily a concept used in the transport layer of the Internet protocol suite or session layer of the OSI model.