No timeout on RTCS FTP server ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

No timeout on RTCS FTP server ?

Jump to solution
1,025 Views
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

Labels (1)
0 Kudos
Reply
1 Solution
700 Views
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:


View solution in original post

0 Kudos
Reply
2 Replies
700 Views
soledad
NXP Employee
NXP Employee

Hi Luc,

Thank you for share your solution :smileywink:

Regards

Sol

0 Kudos
Reply
701 Views
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 Kudos
Reply