Printing Socket Addresses
If you construct an address for the Simple Mail Transfer Protocol (SMTP) port on Rogue Wave’s mail gateway using this code:
 
RWSockAddr addr = "inet:roguewave.com:25";
you can print the address using this code:
 
cout << addr;
The output is:
 
roguewave.com:25
You can also use the function RWSocket::id() to get an ASCII representation of the socket address. You can print the address using this code:
 
cout << addr.id();
The id() function enables you to tailor the amount of output by supplying an optional argument. The argument is an integer between 0 and 9, and (in general) controls the amount of output—the higher the argument, the more descriptive the output.
For example, addr.id(9) returns the string:
 
inet:stream:roguewave.com(198.68.9.6):25(smtp,mail).
Table 1 shows sample output from id() for each value of its parameter for an Internet stream address. Other address types will have different output.
Table 1 – Behavior of id and sample output for an Internet stream address 
Parameter provided to id()
May access network
Always includes family field
Sample output for id(parameter) given RWInetAddr( "198.68.9.6:mail" )
0(default)
 
 
198.68.9.6:mail
1
 
 
198.68.9.6:mail
2
 
 
inet:stream:198.68.9.6:mail
3
X
 
roguewave.com:25
4
X
 
roguewave.com(198.68.9.6):25(smtp)
5
X
 
roguewave.com(198.68.9.6):25(smtp)
6
X
X
inet:stream:roguewave.com:25
7
X
X
inet:stream:roguewave.com(198.68.9.6):25(smtp)
8
X
X
inet:stream:roguewave.com(198.68.9.6):25(smtp)
9
X
X
inet:stream:roguewave.com(198.68.9.6):25(smtp,mail)