#ifndef _DRAGONNET_ADDR_H_
#define _DRAGONNET_ADDR_H_
-#include <netdb.h>
-#include <sys/socket.h>
-#include <sys/types.h>
+#include "sock.h"
struct addrinfo *dragonnet_str2addr(const char *str);
char *dragonnet_addr2str(struct sockaddr *addr, socklen_t addr_len);
#include <dragonnet/listen.h>
#include <dragonnet/recv.h>
#include <errno.h>
-#include <features.h>
-#include <netdb.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/socket.h>
-#include <unistd.h>
+#include "sock.h"
// ----
// Peer
l->on_recv_type = calloc(sizeof *l->on_recv_type, dragonnet_num_types);
int so_reuseaddr = 1;
- if (setsockopt(l->sock, SOL_SOCKET, SO_REUSEADDR, &so_reuseaddr,
+ if (setsockopt(l->sock, SOL_SOCKET, SO_REUSEADDR, (void *) &so_reuseaddr,
sizeof so_reuseaddr) < 0) {
perror("setsockopt");
freeaddrinfo(info);
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
+#include "sock.h"
static bool dragonnet_peer_init(DragonnetPeer *p, char *addr)
{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/socket.h>
-#include <sys/types.h>
#include <unistd.h>
+#include "sock.h"
bool dragonnet_recv_raw(DragonnetPeer *p, void *buf, size_t n)
{
#include <dragonnet/peer.h>
#include <dragonnet/recv.h>
#include <dragonnet/recv_thread.h>
+#include <endian.h/endian.h>
#include <errno.h>
-#include <features.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/socket.h>
-#include <sys/types.h>
#include <unistd.h>
+#include "sock.h"
void *dragonnet_peer_recv_thread(void *g_peer)
{
bool reset = false;
- ssize_t len = recv(p->sock, &type_id, sizeof type_id, MSG_WAITALL);
+ ssize_t len = recv(p->sock, (void *) &type_id, sizeof type_id, MSG_WAITALL);
if (len < 0) {
if (errno == ECONNRESET || errno == EPIPE || errno == ETIMEDOUT) {
reset = true;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/socket.h>
-#include <sys/types.h>
+#include "sock.h"
bool dragonnet_send_raw(DragonnetPeer *p, bool submit, const void *buf, size_t n)
{
--- /dev/null
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <iphlpapi.h>
+#include <ws2def.h>
+#include <windows.h>
+#include <io.h>
+#define SHUT_RDWR SD_BOTH
+#define MSG_NOSIGNAL 0
+#define MSG_MORE 0
+#else
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#endif