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
61f4e183
Commit
61f4e183
authored
Jan 01, 2017
by
Marcel Stör
Browse files
Use an executable example for net.socket:on()
parent
f8f10692
Changes
1
Hide whitespace changes
Inline
Side-by-side
docs/en/modules/net.md
View file @
61f4e183
...
...
@@ -310,11 +310,11 @@ Otherwise, all connection errors (with normal close) passed to disconnection eve
```
lua
srv
=
net
.
createConnection
(
net
.
TCP
,
0
)
srv
:
on
(
"receive"
,
function
(
sck
,
c
)
print
(
c
)
end
)
srv
:
on
(
"connection"
,
function
(
sck
)
srv
:
on
(
"connection"
,
function
(
sck
,
c
)
-- Wait for connection before sending.
sck
:
send
(
"GET / HTTP/1.1\r\nHost:
192.168.0.66
\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n"
)
sck
:
send
(
"GET /
get
HTTP/1.1\r\nHost:
httpbin.org
\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n"
)
end
)
srv
:
connect
(
80
,
"
192.168.0.66
"
)
srv
:
connect
(
80
,
"
httpbin.org
"
)
```
#### See also
...
...
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