Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
afd974c5
Commit
afd974c5
authored
May 22, 2016
by
Marcel Stör
Browse files
Correct socket:send example, fixes #1303
parent
498cc52a
Changes
1
Hide whitespace changes
Inline
Side-by-side
docs/en/modules/net.md
View file @
afd974c5
...
@@ -304,18 +304,19 @@ srv:listen(80, function(conn)
...
@@ -304,18 +304,19 @@ srv:listen(80, function(conn)
response
[
#
response
+
1
]
=
"e.g. content read from a file"
response
[
#
response
+
1
]
=
"e.g. content read from a file"
-- sends and removes the first element from the 'response' table
-- sends and removes the first element from the 'response' table
local
function
send
()
local
function
send
(
sk
)
if
#
response
>
0
if
#
response
>
0
then
s
c
k
:
send
(
table.remove
(
response
,
1
))
then
sk
:
send
(
table.remove
(
response
,
1
))
else
else
sck
:
close
()
sk
:
close
()
response
=
nil
end
end
end
end
-- triggers the send() function again once the first chunk of data was sent
-- triggers the send() function again once the first chunk of data was sent
sck
:
on
(
"sent"
,
send
)
sck
:
on
(
"sent"
,
send
)
send
()
send
(
sck
)
end
)
end
)
end
)
end
)
```
```
...
@@ -326,8 +327,8 @@ sck:send(header, function()
...
@@ -326,8 +327,8 @@ sck:send(header, function()
local
data1
=
"some large chunk of dynamically loaded data"
local
data1
=
"some large chunk of dynamically loaded data"
sck
:
send
(
data1
,
function
()
sck
:
send
(
data1
,
function
()
local
data2
=
"even more dynamically loaded data"
local
data2
=
"even more dynamically loaded data"
sck
:
send
(
data2
,
function
()
sck
:
send
(
data2
,
function
(
sk
)
s
c
k
:
close
()
sk
:
close
()
end
)
end
)
end
)
end
)
end
)
end
)
...
...
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