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