fix BSD compile issue, added some debug, OSX compile fixes

pull/1/head
Ryan Tharp 6 years ago
parent 3f6a5c4ca5
commit 34dca85780

@ -5,18 +5,24 @@
#if __FreeBSD__
// kqueue / kevent
//# include <sys/types.h> // already in net.h
# include <sys/event.h>
# include <sys/time.h>
#endif
#if (__APPLE__ && __MACH__)
// kqueue / kevent
# include <sys/event.h>
# include <sys/time.h>
#endif
//#include <sys/socket.h>
//#include <ifaddrs.h>
// MacOS needs this
#ifndef SOCK_NONBLOCK
# include <fcntl.h>
# define SOCK_NONBLOCK O_NONBLOCK
#endif
// original upstream
#include <unistd.h>
#include <cstdio>
#include "ev.hpp"
#include "logger.hpp"
@ -50,7 +56,9 @@ namespace llarp
virtual int
sendto(const sockaddr* to, const void* data, size_t sz)
{
printf("kqueue:::udp_listener::sendto size[%d]\n", sz);
socklen_t slen;
printf("kqueue:::udp_listener::sendto af[%d]\n", to->sa_family);
switch(to->sa_family)
{
case AF_INET:
@ -62,9 +70,10 @@ namespace llarp
default:
return -1;
}
printf("kqueue:::udp_listener::sendto slen[%d]\n", slen);
ssize_t sent = ::sendto(fd, data, sz, SOCK_NONBLOCK, to, slen);
if(sent == -1)
perror("sendto()");
perror("kqueue sendto()");
return sent;
}
};
@ -164,7 +173,7 @@ struct llarp_kqueue_loop : public llarp_ev_loop
}
}
llarp::Addr a(*addr);
llarp::Info(__FILE__, "bind to ", a.to_string());
llarp::Info(__FILE__, "bind to ", a);
if(bind(fd, addr, slen) == -1)
{
perror("bind()");

Loading…
Cancel
Save