No timeout on RTCS FTP server ?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

No timeout on RTCS FTP server ?

跳至解决方案
1,026 次查看
lucky06200
Contributor II

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

标签 (1)
标记 (5)
0 项奖励
回复
1 解答
701 次查看
lucky06200
Contributor II

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:


在原帖中查看解决方案

0 项奖励
回复
2 回复数
701 次查看
soledad
NXP Employee
NXP Employee

Hi Luc,

Thank you for share your solution :smileywink:

Regards

Sol

0 项奖励
回复
702 次查看
lucky06200
Contributor II

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:


0 项奖励
回复