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
6bce18f9
Commit
6bce18f9
authored
Dec 30, 2016
by
Johny Mattsson
Browse files
net module: Server timeout support
As per @djphoenix's version on the ESP8266 side.
parent
334ba081
Changes
1
Hide whitespace changes
Inline
Side-by-side
components/modules/net.c
View file @
6bce18f9
...
...
@@ -52,6 +52,7 @@ typedef struct lnet_userdata {
union
{
struct
{
int
cb_accept_ref
;
int
timeout
;
}
server
;
struct
{
int
wait_dns
;
...
...
@@ -351,9 +352,8 @@ int net_createServer( lua_State *L ) {
if
(
type
==
TYPE_UDP
)
return
net_createUDPSocket
(
L
);
if
(
type
!=
TYPE_TCP
)
return
luaL_error
(
L
,
"invalid type"
);
net_create
(
L
,
TYPE_TCP_SERVER
);
// TODO: timeout
(
void
)
timeout
;
lnet_userdata
*
ud
=
net_create
(
L
,
TYPE_TCP_SERVER
);
ud
->
server
.
timeout
=
timeout
;
return
1
;
}
...
...
@@ -1020,7 +1020,9 @@ static void laccept_cb (lua_State *L, lnet_userdata *ud, struct tcp_pcb *newpcb)
tcp_err
(
nud
->
tcp_pcb
,
net_err_cb
);
tcp_recv
(
nud
->
tcp_pcb
,
net_tcp_recv_cb
);
tcp_sent
(
nud
->
tcp_pcb
,
net_sent_cb
);
nud
->
tcp_pcb
->
so_options
|=
SOF_KEEPALIVE
;
nud
->
tcp_pcb
->
keep_idle
=
ud
->
server
.
timeout
*
1000
;
nud
->
tcp_pcb
->
keep_cnt
=
1
;
tcp_accepted
(
ud
->
tcp_pcb
);
lua_call
(
L
,
1
,
0
);
...
...
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