dns.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <meta name="description" content="LuaSocket: DNS support">
  6. <meta name="keywords" content="Lua, LuaSocket, DNS, Network, Library, Support">
  7. <title>LuaSocket: DNS support</title>
  8. <link rel="stylesheet" href="reference.css" type="text/css">
  9. </head>
  10. <body>
  11. <!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  12. <div class=header>
  13. <hr>
  14. <center>
  15. <table summary="LuaSocket logo">
  16. <tr><td align=center><a href="http://www.lua.org">
  17. <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
  18. </a></td></tr>
  19. <tr><td align=center valign=top>Network support for the Lua language
  20. </td></tr>
  21. </table>
  22. <p class=bar>
  23. <a href="index.html">home</a> &middot;
  24. <a href="index.html#download">download</a> &middot;
  25. <a href="installation.html">installation</a> &middot;
  26. <a href="introduction.html">introduction</a> &middot;
  27. <a href="reference.html">reference</a>
  28. </p>
  29. </center>
  30. <hr>
  31. </div>
  32. <!-- dns ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  33. <h2 id=dns>DNS</h2>
  34. <p>
  35. IPv4 name resolution functions
  36. <a href=#toip><tt>dns.toip</tt></a>
  37. and
  38. <a href=#tohostname><tt>dns.tohostname</tt></a>
  39. return <em>all</em> information obtained from
  40. the resolver in a table of the form:
  41. </p>
  42. <blockquote><tt>
  43. resolved4 = {<br>
  44. &nbsp;&nbsp;name = <i>canonic-name</i>,<br>
  45. &nbsp;&nbsp;alias = <i>alias-list</i>,<br>
  46. &nbsp;&nbsp;ip = <i>ip-address-list</i><br>
  47. }
  48. </tt> </blockquote>
  49. <p>
  50. Note that the <tt>alias</tt> list can be empty.
  51. </p>
  52. <p>
  53. The more general name resolution function
  54. <a href=#getaddrinfo><tt>dns.getaddrinfo</tt></a>, which
  55. supports both IPv6 and IPv4,
  56. returns <em>all</em> information obtained from
  57. the resolver in a table of the form:
  58. </p>
  59. <blockquote><tt>
  60. resolved6 = {<br>
  61. &nbsp;&nbsp;[1] = {<br>
  62. &nbsp;&nbsp;&nbsp;&nbsp;family = <i>family-name-1</i>,<br>
  63. &nbsp;&nbsp;&nbsp;&nbsp;addr = <i>address-1</i><br>
  64. &nbsp;&nbsp;},<br>
  65. &nbsp;&nbsp;...<br>
  66. &nbsp;&nbsp;[n] = {<br>
  67. &nbsp;&nbsp;&nbsp;&nbsp;family = <i>family-name-n</i>,<br>
  68. &nbsp;&nbsp;&nbsp;&nbsp;addr = <i>address-n</i><br>
  69. &nbsp;&nbsp;}<br>
  70. }
  71. </tt> </blockquote>
  72. <p>
  73. Here, <tt>family</tt> contains the string <tt>"inet"</tt> for IPv4
  74. addresses, and <tt>"inet6"</tt> for IPv6 addresses.
  75. </p>
  76. <!-- getaddrinfo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  77. <p class=name id=getaddrinfo>
  78. socket.dns.<b>getaddrinfo(</b>address<b>)</b>
  79. </p>
  80. <p class=description>
  81. Converts from host name to address.
  82. </p>
  83. <p class=parameters>
  84. <tt>Address</tt> can be an IPv4 or IPv6 address or host name.
  85. </p>
  86. <p class=return>
  87. The function returns a table with all information returned by
  88. the resolver. In case of error, the function returns <b><tt>nil</tt></b>
  89. followed by an error message.
  90. </p>
  91. <!-- gethostname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  92. <p class=name id=gethostname>
  93. socket.dns.<b>gethostname()</b>
  94. </p>
  95. <p class=description>
  96. Returns the standard host name for the machine as a string.
  97. </p>
  98. <!-- tohostname +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  99. <p class=name id=tohostname>
  100. socket.dns.<b>tohostname(</b>address<b>)</b>
  101. </p>
  102. <p class=description>
  103. Converts from IPv4 address to host name.
  104. </p>
  105. <p class=parameters>
  106. <tt>Address</tt> can be an IP address or host name.
  107. </p>
  108. <p class=return>
  109. The function returns a string with the canonic host name of the given
  110. <tt>address</tt>, followed by a table with all information returned by
  111. the resolver. In case of error, the function returns <b><tt>nil</tt></b>
  112. followed by an error message.
  113. </p>
  114. <!-- toip +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  115. <p class=name id=toip>
  116. socket.dns.<b>toip(</b>address<b>)</b>
  117. </p>
  118. <p class=description>
  119. Converts from host name to IPv4 address.
  120. </p>
  121. <p class=parameters>
  122. <tt>Address</tt> can be an IP address or host name.
  123. </p>
  124. <p class=return>
  125. Returns a string with the first IP address found for <tt>address</tt>,
  126. followed by a table with all information returned by the resolver.
  127. In case of error, the function returns <b><tt>nil</tt></b> followed by an error
  128. message.
  129. </p>
  130. <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  131. <div class=footer>
  132. <hr>
  133. <center>
  134. <p class=bar>
  135. <a href="index.html">home</a> &middot;
  136. <a href="index.html#down">download</a> &middot;
  137. <a href="installation.html">installation</a> &middot;
  138. <a href="introduction.html">introduction</a> &middot;
  139. <a href="reference.html">reference</a>
  140. </p>
  141. <p>
  142. <small>
  143. Last modified by Diego Nehab on <br>
  144. Thu Apr 20 00:25:07 EDT 2006
  145. </small>
  146. </p>
  147. </center>
  148. </div>
  149. </body>
  150. </html>