jsbsim icon indicating copy to clipboard operation
jsbsim copied to clipboard

Fix the telnet connection on Windows

Open bcoconni opened this issue 3 years ago • 1 comments

This pull request should fix the bug reported in issue #698 and discussion #693:

  • Error codes returned by socket() and append() should now be correctly handled on Windows (the SOCKET type is a pointer type).
  • JSBSim no longer expects telnet to be in line mode. Actually, the default telnet on Windows cannot be set to line mode so recv() sends one character at a time instead of a string. This PR modifies FGInputSocket to append the data received from the socket in a buffer. The buffer is parsed once it contains a CARRIAGE RETURN \r or a LINE FEED \n.

As per @seanmcleod's suggestion, dummy flags INVALID_SOCKET and SOCKET_ERROR are defined for non-Windows platforms to use the same syntax for all platforms and save a lot of #ifdef.

bcoconni avatar Aug 08 '22 11:08 bcoconni

I took the opportunity of this PR to fix the test TestInputSocket so that it should now work on Windows and MacOSX.

I removed the threading code altogether as this was not needed and the test is now taking place in a single thread. The resulting code is much more straightforward and achieves the goal of testing whether the input socket is working or not on the 3 platforms that we are supporting (instead of Linux alone).

bcoconni avatar Aug 09 '22 11:08 bcoconni