A socket type represents the type of communication channel for which a socket serves as an endpoint. Usually, you don't have to worry about the type, as sensible defaults are always provided by the net library; most net users can skip this section.
There are three components to a socket's type:
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. Some example families, and their associated constant and string identifiers, are given in the following table.
Family |
Integer identifier |
String identifier |
Internet |
AF_INET |
"inet" |
The only family fully implemented in Tools.h++ Professional 1.2 is the Internet protocol family. However, as we describe later, the open architecture used for socket addresses allows you to add your own address families.
Type
The communication semantics of the channel are indicated through an integer type, as shown in the following table. As indicated in the following table, not all types are supported by Tools.h++ Professional 1.0.
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; usually the protocol indicated by the family and type of the socket is all that is necessary. The specific values allowed for the protocol vary from address family to address family.
In the net library, a socket address type is represented by an RWSockType object. This is a concrete class: there are no virtual functions, and it has straightforward and efficient copying and assignment semantics. Derived classes are provided for ease of construction of types for each address family. For example, the RWInetType class can be used to construct an RWSockType for the Internet family of classes. Since RWSockType is a concrete class, these derived classes can be converted to instances of RWSockType with no change in the semantics of the object.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.