/doc/inet.utils.html
HTML | 49 lines | 44 code | 1 blank | 4 comment | 0 complexity | 422540f230a1fe805ca82259e79fdddb MD5 | raw file
1<html><!-- #BeginTemplate "/Templates/tmpl.dwt" --><!-- DW6 --> 2<head> 3<!-- #BeginEditable "doctitle" --> 4<title>PTypes: networking: utilities</title> 5<!-- #EndEditable --> 6<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 7<link rel="stylesheet" href="styles.css"> 8</head> 9<body bgcolor="#FFFFFF" leftmargin="40" marginwidth="40"> 10<p><a href="../index.html"><img src="title-21.png" width="253" height="39" alt="C++ Portable Types Library (PTypes) Version 2.1" border="0"></a> 11<hr size="1" noshade> 12<!-- #BeginEditable "body" --> 13<p class="hpath"><a href="index.html">Top</a>: <a href="inet.html">Networking</a>: 14Utilities</p> 15<blockquote> 16<pre class="lang">#include <pinet.h> 17 18string iptostring(ipaddress ip); 19ipaddress phostbyname(const string& name); 20string phostbyaddr(ipaddress ip); 21string phostcname(const string& name); 22</pre> 23</blockquote> 24<p>Many PTypes networking utility functions and class methods manipulate a new 25data type <span class="lang">ipaddress</span> - IPv4 (4-byte) internetwork address 26type. The objects of this type can be constructed either by explicitly specifying 27the 4 bytes separately (e.g. <span class="lang">ipaddress(192, 168, 1, 1)</span>) 28or by assigning another <span class="lang">ipaddress</span>. The objects of this 29type are mutually compatible with <span class="lang">unsigned long</span> type, 30however, you can not rely on the order of bytes if an <span class="lang">ipaddress</span> 31is converted to a <span class="lang">unsigned long</span> and vice versa. This 32implicit typecast is provided only for comparing an <span class="lang">ipaddress</span> 33value with 0 or <span class="lang">ipnone</span> (see <a href="inet.examples.html">Examples</a>).</p> 34<p><span class="def">string iptostring(ipaddress ip)</span> converts an IP address 35to a string, e.g. <span class="lang">ipaddress(127, 0, 0, 1)</span> would be "127.0.0.1".</p> 36<p><span class="def">ipaddress phostbyname(const string& name)</span> resolves 37a symbolic DNS name or a numeric IP addresses to <span class="lang">ipaddress</span>. 38On error this function returns <span class="lang">ipnone</span>.</p> 39<p><span class="def">string phostbyaddr(ipaddress ip)</span> performs reverse 40DNS lookup for the given IP address. On error this function returns an empty string.</p> 41<p><span class="def">string phostcname(const string& name)</span> returns 42the canonical name of the host. On error this function returns an empty string.</p> 43<p class="seealso">See also: <a href="inet.ipstream.html">ipstream</a>, <a href="inet.ipstmserver.html">ipstmserver</a>, 44<a href="inet.examples.html">Examples</a></p> 45<!-- #EndEditable --> 46<hr size="1"> 47<a href="../index.html" class="ns">PTypes home</a> 48</body> 49<!-- #EndTemplate --></html>