mavlink socket: stream to localhost before actually receiving packets

This commit is contained in:
tumbili
2015-09-04 15:02:04 +02:00
committed by Lorenz Meier
parent d93337017d
commit 4fae86b5ac
3 changed files with 15 additions and 5 deletions
+7
View File
@@ -1776,6 +1776,13 @@ MavlinkReceiver::receive_thread(void *arg)
} else {
// could be TCP or other protocol
}
struct sockaddr_in * srcaddr_last = _mavlink->get_client_source_address();
int localhost = (127 << 24) + 1;
if (srcaddr_last->sin_addr.s_addr == htonl(localhost) && srcaddr.sin_addr.s_addr != htonl(localhost)) {
// if we were sending to localhost before but have a new host then accept him
memcpy(srcaddr_last, &srcaddr, sizeof(srcaddr));
}
#endif
/* if read failed, this loop won't execute */
for (ssize_t i = 0; i < nread; i++) {