AP_HAL_SITL: reorder setting SO_REUSEADDR and binding rc in port

This stops things failing on cygwin, and may explain rebind failures we
see in SITL.
This commit is contained in:
Peter Barker 2018-12-19 21:44:34 +11:00 committed by Francisco Ferreira
parent 447fab595e
commit 3d08d02a66
1 changed files with 4 additions and 4 deletions

View File

@ -117,13 +117,13 @@ void SITL_State::_sitl_setup(const char *home_str)
*/
void SITL_State::_setup_fdm(void)
{
if (!_sitl_rc_in.bind("0.0.0.0", _rcin_port)) {
fprintf(stderr, "SITL: socket bind failed on RC in port : %d - %s\n", _rcin_port, strerror(errno));
if (!_sitl_rc_in.reuseaddress()) {
fprintf(stderr, "SITL: socket reuseaddress failed on RC in port: %d - %s\n", _rcin_port, strerror(errno));
fprintf(stderr, "Aborting launch...\n");
exit(1);
}
if (!_sitl_rc_in.reuseaddress()) {
fprintf(stderr, "SITL: socket reuseaddress failed on RC in port: %d - %s\n", _rcin_port, strerror(errno));
if (!_sitl_rc_in.bind("0.0.0.0", _rcin_port)) {
fprintf(stderr, "SITL: socket bind failed on RC in port : %d - %s\n", _rcin_port, strerror(errno));
fprintf(stderr, "Aborting launch...\n");
exit(1);
}