Sockets are characterized by three attributes: domain, type and protocol.
int socket(int domain, int type , int protocol);
- socket domains: domain basically describes the network medium that is used by the sockets for communication. the most common domain used is AF_INET, for Internet networking and AF_UNIX for UNIX file system domain used on a single computer that isn’t networked.
- socket types: In sockets, there are two methods for transferring data: stream and datagrams. stream sockets: It provides a connection link between the client and the server process.It is specified by the type SOCK_STREAM. datagrams: It provides the connectionless link between the client and server process. It is specified by the type SOCK_DGRAM.
- socket protocols: protocols depends on the type of socket used. If socket type is SOCK_STREAM then TCP/IP protocol is used. If the socket type is SOCK_DGRAM then UDP/IP protocol is used.