-`event` string, which can be "connection", "reconnection", "disconnection", "receive" or "sent"
-`function(net.socket, [string])` callback function. The first parameter is the socket. If event is "receive", the second parameter is the received data as string.
-`string` data in string which will be sent to server
-`function(sent)` callback function for sending string
#### Returns
`nil`
#### Note
Multiple consecutive `send()` calls aren't guaranteed to work (and often don't) as network requests are treated as separate tasks by the SDK. Instead, subscribe to the "sent" event on the socket and send additional data (or close) in that callback. See [#730](https://github.com/nodemcu/nodemcu-firmware/issues/730#issuecomment-154241161) for an example and explanation.
#### See also
[`net.socket:on()`](#netsocketon)
# net.dns Module
## net.dns.getdnsserver()
Gets the IP address of the DNS server used to resolve hostnames.
#### Syntax
`net.dns.getdnsserver(dns_index)`
#### Parameters
dns_index which DNS server to get (range 0~1)
#### Returns
IP address (string) of DNS server
#### Example
```lua
print(net.dns.getdnsserver(0))-- 208.67.222.222
print(net.dns.getdnsserver(1))-- nil
net.dns.setdnsserver("8.8.8.8",0)
net.dns.setdnsserver("192.168.1.252",1)
print(net.dns.getdnsserver(0))-- 8.8.8.8
print(net.dns.getdnsserver(1))-- 192.168.1.252
```
#### See also
[`net.dns:setdnsserver()`](#netdnssetdnsserver)
## net.dns.resolve()
Resolve a hostname to an IP address. Doesn't require a socket like [`net.socket.dns()`](#netsocketdns).
#### Syntax
`net.dns.resolve(host, function(ip))`
#### Parameters
-`host` hostname to resolve
-`function(sk, ip)` callback called when the name was resolved. Don't use `sk`, it's a socket used internally to resolve the hostname.
#### Returns
`nil`
#### Example
```lua
net.dns.resolve("www.google.com",function(sk,ip)
if(ip==nil)thenprint("DNS fail!")elseprint(ip)end
end)
```
#### See also
[`net.socket:dns()`](#netsocketdns)
## net.dns.setdnsserver()
Sets the IP of the DNS server used to resolve hostnames. Default: resolver1.opendns.com (208.67.222.222). You can specify up to 2 DNS servers.
#### Syntax
`net.dns.setdnsserver(dns_ip_addr, dns_index)`
#### Parameters
-`dns_ip_addr` IP address of a DNS server
-`dns_index` which DNS server to set (range 0~1). Hence, it supports max. 2 servers.