#include "misc.hh"
#include <boost/lexical_cast.hpp>
#include "syncres.hh"
+#include "utility.hh"
using namespace boost;
using namespace std;
struct timeval tv={0,500000};
int ret=select(fdmax + 1, &readfds, &writefds, 0, &tv);
- gettimeofday(now, 0);
+ Utility::gettimeofday(now, 0);
if(ret < 0 && errno!=EINTR)
throw FDMultiplexerException("select returned error: "+stringerror());
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
+#ifndef WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/select.h>
+#endif
#include <fcntl.h>
#include <stdexcept>
#include <boost/shared_ptr.hpp>
IPAddress(const string &remote)
{
struct in_addr addr;
- if(!inet_aton(remote.c_str(), &addr))
+ if(!Utility::inet_aton(remote.c_str(), &addr))
throw NetworkError("Could not convert '"+remote+"' to an IP address");
byte=addr.s_addr;
}
//! Set the socket to non-blocking
void setNonBlocking()
{
- int flags=fcntl(d_socket,F_GETFL,0);
- if(flags<0 || fcntl(d_socket, F_SETFL,flags|O_NONBLOCK) <0)
- throw NetworkError("Setting socket to nonblocking: "+string(strerror(errno)));
+ Utility::setNonBlocking(d_socket);
}
//! Bind the socket to a specified endpoint
return *tv;
else {
struct timeval ret;
- gettimeofday(&ret, 0);
+ Utility::gettimeofday(&ret, 0);
return ret;
}
}
public:
PulseRate() : d_val(0.0)
{
- gettimeofday(&d_last, 0);
+ Utility::gettimeofday(&d_last, 0);
}
PulseRate(const PulseRate& orig) : d_last(orig.d_last), d_val(orig.d_val)