mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-28 02:40:35 +08:00
make socket non-blocking, moved socket includes to header file to avoid forward declarations
This commit is contained in:
@@ -45,10 +45,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <drivers/drv_led.h>
|
||||
#ifndef __PX4_QURT
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include "simulator.h"
|
||||
|
||||
using namespace simulator;
|
||||
@@ -378,6 +375,11 @@ void Simulator::updateSamples()
|
||||
// this is used to time message sending
|
||||
_time_last = hrt_absolute_time();
|
||||
|
||||
// make socket non-blocking
|
||||
int flags = fcntl(_fd,F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
fcntl(_fd, F_SETFL, flags);
|
||||
|
||||
int len = 0;
|
||||
// wait for new mavlink messages to arrive
|
||||
for (;;) {
|
||||
|
||||
Reference in New Issue
Block a user