A socket is an abstract communication “end point”. For example, when a TCP connection is established, the origin (requester of the connection) has a socket, and the destination (acceptor of the connection) has another socket. The two ends of the connection can read from or write to the sockets to communicate with each other.
As such, a socket has no associated storage, and do not natively support seek operations. Read/write operations are supported, however.
It is important to differentiate a socket from a network port. A network port, such as port 22 (for SSH connections), is nothing more than a part of an address. Each interface can only have one port 22. However, a socket represents an active (in-use) instance of connection, possibly to a particular port of an interface. This means that port 22 of an interface, say 127.0.0.1, can have any number of sockets associated with it, from 0 (no connection) to as many connections as affordable by system resources.
Not all sockets are represented by vnodes. A socket can exist namelessly and owned by a process merely as a data structure without being represented by a vnode in the file system. A socket that exists as a vnode in the file system can exist independent to the process that creates it, and be accessed by any process that has the privilege and permission to do so.
For example, the VDE (virtual distributed ethernet) framework uses the vde_switch program to create a named socket. The program slirpvde is used to implement a virtual DHCP server and a bridge to the network gateway of the host environment. These two separate programs (run as two processes) only need to agree on the path to the named socket.
All sockets have the following attributes.