SITL: Make socket error more verbose

This commit is contained in:
Pierre Kancir 2016-11-21 14:15:00 +01:00 committed by Andrew Tridgell
parent 8f2bdf51ea
commit 567a8d68e5
2 changed files with 6 additions and 3 deletions

View File

@ -117,7 +117,8 @@ 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 - %s\n", strerror(errno));
fprintf(stderr, "SITL: socket bind failed on RC in port : %d - %s\n", _rcin_port, strerror(errno));
fprintf(stderr, "Abording launch...\n");
exit(1);
}
_sitl_rc_in.reuseaddress();

View File

@ -418,14 +418,16 @@ void Aircraft::set_speedup(float speedup)
void Aircraft::set_interface_ports(const char* address, const int port_in, const int port_out)
{
if (!socket_in.bind("127.0.0.1", port_in)) {
fprintf(stderr, "SITL: socket in bind failed - %s\n", strerror(errno));
fprintf(stderr, "SITL: socket in bind failed on sim in : %d - %s\n", port_in, strerror(errno));
fprintf(stderr, "Abording launch...\n");
exit(1);
}
socket_in.reuseaddress();
socket_in.set_blocking(false);
if (!socket_out.connect(address, port_out)) {
fprintf(stderr, "SITL: socket out bind failed - %s\n", strerror(errno));
fprintf(stderr, "SITL: socket out bind failed on sim out : %d - %s\n", port_out, strerror(errno));
fprintf(stderr, "Abording launch...\n");
exit(1);
}
socket_out.reuseaddress();