Understanding Socket Types
A socket’s type has three components:
Family A socket family indicates which protocol and address family is used with this socket. The family may be represented with either an integer constant or a string. A sample family and the associated integer and string identifiers are shown below.
Family | Integer identifier | String identifier |
Internet | AF_INET | “inet” |
The only family fully implemented in the Networking package is the Internet protocol family. However, you can add your own address families.
Type The communication semantics of the channel are indicated through an integer type, as shown below. The Networking package does not support all types.
Type | Integer identifier | String identifier |
---|
Datagram socket | SOCK_DGRAM | “dgram” |
Stream socket | SOCK_STREAM | “stream” |
Protocol The protocol specifies a specific protocol to be used by the channel. Generally only experts need this feature. The protocol indicated by the family and type of the socket is all that is necessary. The specific values allowed for the protocol vary.