make socket non-blocking, moved socket includes to header file to avoid forward declarations

This commit is contained in:
tumbili 2015-05-09 10:10:23 +02:00
parent 39711ca908
commit 9119687177
2 changed files with 10 additions and 4 deletions

View File

@ -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 (;;) {

View File

@ -51,6 +51,10 @@
#include <uORB/uORB.h>
#include <v1.0/mavlink_types.h>
#include <v1.0/common/mavlink.h>
#include <sys/socket.h>
#ifndef __PX4_QURT
#include <netinet/in.h>
#endif
namespace simulator {