Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
0ca4b6ba
Commit
0ca4b6ba
authored
Feb 01, 2017
by
Marcel Stör
Browse files
Add more UDP documentation, contributes to #1701
parent
419ec338
Changes
1
Hide whitespace changes
Inline
Side-by-side
docs/en/modules/net.md
View file @
0ca4b6ba
...
...
@@ -451,6 +451,35 @@ The syntax and functional similar to [`net.socket:on()`](#netsocketon). However,
Sends data to specific remote peer.
#### Syntax
`send(port, ip, data)`
#### Parameters
-
`port`
remote socket port
-
`ip`
remote socket IP
-
`data`
the payload to send
#### Returns
`nil`
#### Example
```
lua
udpSocket
=
net
.
createUDPSocket
()
udpSocket
:
listen
(
5000
)
udpSocket
:
on
(
"receive"
,
function
(
s
,
data
,
port
,
ip
)
print
(
string.format
(
"received '%s' from %s:%d"
,
data
,
ip
,
port
))
s
:
send
(
port
,
ip
,
"echo: "
..
data
)
end
)
port
,
ip
=
udpSocket
:
getaddr
()
print
(
string.format
(
"local UDP socket address / port: %s:%d"
,
ip
,
port
))
```
On
*
nix systems that can then be tested by issuing
```
echo -n "foo" | nc -w1 -u <device-IP-address> 5000
```
## net.udpsocket:dns()
Provides DNS resolution for a hostname.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment