/doc/inet.utils.html

http://github.com/foodmike/PTypes · 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>:
  14. Utilities</p>
  15. <blockquote>
  16. <pre class="lang">#include &lt;pinet.h&gt;
  17. string iptostring(ipaddress ip);
  18. ipaddress phostbyname(const string&amp; name);
  19. string phostbyaddr(ipaddress ip);
  20. string phostcname(const string&amp; name);
  21. </pre>
  22. </blockquote>
  23. <p>Many PTypes networking utility functions and class methods manipulate a new
  24. data type <span class="lang">ipaddress</span> - IPv4 (4-byte) internetwork address
  25. type. The objects of this type can be constructed either by explicitly specifying
  26. the 4 bytes separately (e.g. <span class="lang">ipaddress(192, 168, 1, 1)</span>)
  27. or by assigning another <span class="lang">ipaddress</span>. The objects of this
  28. type are mutually compatible with <span class="lang">unsigned long</span> type,
  29. however, you can not rely on the order of bytes if an <span class="lang">ipaddress</span>
  30. is converted to a <span class="lang">unsigned long</span> and vice versa. This
  31. implicit typecast is provided only for comparing an <span class="lang">ipaddress</span>
  32. value with 0 or <span class="lang">ipnone</span> (see <a href="inet.examples.html">Examples</a>).</p>
  33. <p><span class="def">string iptostring(ipaddress ip)</span> converts an IP address
  34. to a string, e.g. <span class="lang">ipaddress(127, 0, 0, 1)</span> would be &quot;127.0.0.1&quot;.</p>
  35. <p><span class="def">ipaddress phostbyname(const string&amp; name)</span> resolves
  36. a symbolic DNS name or a numeric IP addresses to <span class="lang">ipaddress</span>.
  37. On error this function returns <span class="lang">ipnone</span>.</p>
  38. <p><span class="def">string phostbyaddr(ipaddress ip)</span> performs reverse
  39. DNS lookup for the given IP address. On error this function returns an empty string.</p>
  40. <p><span class="def">string phostcname(const string&amp; name)</span> returns
  41. the canonical name of the host. On error this function returns an empty string.</p>
  42. <p class="seealso">See also: <a href="inet.ipstream.html">ipstream</a>, <a href="inet.ipstmserver.html">ipstmserver</a>,
  43. <a href="inet.examples.html">Examples</a></p>
  44. <!-- #EndEditable -->
  45. <hr size="1">
  46. <a href="../index.html" class="ns">PTypes home</a>
  47. </body>
  48. <!-- #EndTemplate --></html>