Building Internet Addresses
Example 10 shows how to build an Internet address object by specifying the port and then the host.
Example 10 – Building internet addresses
RWInetAddr addr1( 3010, "net.roguewave.com" ); //1
RWInetAddr addr2( 3010 ); //2
RWInetAddr addr3( "stream:net.roguewave.com:3010" ); //3
//1 Includes both a port and a host. Automatic type conversion turns the integer 3010 into an RWInetPort, and turns the string into an RWInetHost.
//2 When the host name is omitted, the special host ANY is used. This address connects to any available IP address on the current computer.
//3 Sends the address as a string. The format is the socket type (stream or dgram), followed by the host identifier, followed by a port identifier. The fields are separated by colons. You can omit the socket type and host, which means that both net.roguewave.com:3010 and 3010 are allowed. The default socket type is stream. If only the port number is used, the host defaults to ANY.