libfins icon indicating copy to clipboard operation
libfins copied to clipboard

Dead loop in fins_tcp_recv()

Open shuicuen opened this issue 4 years ago • 6 comments

Using finslib_tcp_connect() connecting PLC, Often the program Dead loop in fins_tcp_recv()

else if ( recv_len < 0 ) { if ( errno == EAGAIN ) {

			finslib_milli_second_sleep( 10 );
			continue;
		}

shuicuen avatar Nov 27 '20 06:11 shuicuen

When the connection terminates or times out, this loop should end eventually. On which operating system and with which compiler suite do you experience the problems?

lammertb avatar Nov 27 '20 09:11 lammertb

Thank you for your reply. I compiled it with vs2013 compiler in win10 system

shuicuen avatar Dec 08 '20 09:12 shuicuen

I'll change the code somewhat to make it possible to exit the loop when a timeout is reached.

lammertb avatar Feb 09 '21 19:02 lammertb

I'll change the code somewhat to make it possible to exit the loop when a timeout is reached.

Hi there, I also experienced this problem when server node is offline after tcp connected. and I don't know how to use the fins_sys_tp::timeout variable is there any document describe it's usage?

elfive avatar Aug 05 '21 08:08 elfive

Does your problem also occur on a Windows based system, or in another environment?

fins_sys_tp::timeout is set internally based on the the value of FINS_TIMEOUT. It uses a monotonic clock in the system. This clock is provided by the finslib_monotonic_sec_timer() function. The implementation is operating system and hardware dependent.

lammertb avatar Aug 13 '21 10:08 lammertb

Yes, it’s running on Windows 10 with both VS2005 and VS2015

elfive avatar Aug 13 '21 10:08 elfive