Hello,
I use ftpd server with only one session on ARM M4 (K60) + MQX 4.0.0 + RTCS 3.08
When active connection exist, and there is no more trafic, server do not close the connection (no timeout).
So, server is locked for other client.
How can i have a connection close when no traffic occurs during a given time ?
Is this possible to change socket option, for example (in ftpd.c code if needed) ?
If yes, wich option is OK for this ?
Or may be i need to write code in my application for this ?
Best regards,
Luc
已解决! 转到解答。
I found a solution to my problem.I add a socket option (FTPDCFG_RECEIVE_TIMEOUT) in FTPd_task.
Something like :
(around line 150)
if (!error) {
option = FTPDCFG_CONNECT_TIMEOUT;
error = setsockopt(listensock, SOL_TCP, OPT_CONNECT_TIMEOUT, &option, sizeof(option));
}
if (!error) {
option = FTPDCFG_TIMEWAIT_TIMEOUT;
error = setsockopt(listensock, SOL_TCP, OPT_TIMEWAIT_TIMEOUT, &option, sizeof(option));
}
if (!error) {
option = FTPDCFG_RECEIVE_TIMEOUT; // Set this value to what you need (360000 for 6 minute, for me)
error = setsockopt(listensock, SOL_TCP, OPT_RECEIVE_TIMEOUT, &option, sizeof(option));
}
if (!error) {
error = bind(listensock, (const sockaddr *)&laddr, sizeof(laddr));
}
if (!error) {
error = listen(listensock, 0);
}
if (error) {
RTCS_task_exit(creator, error);
}
RTCS_task_resume_creator(creator, RTCS_OK);
So, ftpd exit after no trafic during 6 min.
:smileyhappy:
I found a solution to my problem.I add a socket option (FTPDCFG_RECEIVE_TIMEOUT) in FTPd_task.
Something like :
(around line 150)
if (!error) {
option = FTPDCFG_CONNECT_TIMEOUT;
error = setsockopt(listensock, SOL_TCP, OPT_CONNECT_TIMEOUT, &option, sizeof(option));
}
if (!error) {
option = FTPDCFG_TIMEWAIT_TIMEOUT;
error = setsockopt(listensock, SOL_TCP, OPT_TIMEWAIT_TIMEOUT, &option, sizeof(option));
}
if (!error) {
option = FTPDCFG_RECEIVE_TIMEOUT; // Set this value to what you need (360000 for 6 minute, for me)
error = setsockopt(listensock, SOL_TCP, OPT_RECEIVE_TIMEOUT, &option, sizeof(option));
}
if (!error) {
error = bind(listensock, (const sockaddr *)&laddr, sizeof(laddr));
}
if (!error) {
error = listen(listensock, 0);
}
if (error) {
RTCS_task_exit(creator, error);
}
RTCS_task_resume_creator(creator, RTCS_OK);
So, ftpd exit after no trafic during 6 min.
:smileyhappy: