OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
About TINetSocketAddress

Using

The TINetSocketAddress class encapsulates a Winsock Internet address. This class stores a complete Internet address, which includes an address family, a port, and a 32 bit (4 byte) IP address. The Internet address-specific information is stored in the sa_data field of the sockaddr.

All addresses stored by the TSocketAddress class are in network byte ordering. While the address family field (sa_family) is stored in network byte ordering, these families are #defined in winsock.h to values which are already in network byte ordering. Thus, you can simply refer to them by their names (e.g. AF_INET) and not have to call htons() on them.

The TINetSocketAddress class can be thought of as a C++ version of the sockaddr_in class. Some sockets class implementations (e.g. The Distinct corp.) encapsulate only the IP address (u_long) in their version of an address class. However, we feel that a full Internet address encompasses both a port and the 4 byte u_long IP address. You can think of port and addresses in terms of the US Mail system. The IP address (u_long) is like the address on a letter, and the port is like the name of the person that receives the letter at that address. An address on a letter received in the mail is incomplete without the name of who gets the letter. Thus, a full address includes both the address and who should receive the mail at that address. Likewise, a complete Internet address consists of both a port and an address.

There are a number of constructors for TINetSocketAddress. Among them are a copy constructor, an empty constructor, a constructor from a char*, and a constructor from a port and u_long. These constructors set up the sa_data portion of the sockaddr structure to make it look like a properly filled-in sockaddr_in structure. The TINetSocketAddress class also has functions to get and set the addrress information, get address class information, and functions to convert between dotted-decimal and u_long versions of the Internet address (Winsock's inet_ntoa() and inet_addr()).

Many OWL Windows Socket functions expect a TSocketAddress as a parameter. You can pass an TINetSocketAddress or a TSocketAddress as the parameter.