From 97d26055bc56ab134921d21c201507ffa812bcbd Mon Sep 17 00:00:00 2001 From: Simon Newton Date: Sun, 19 Jul 2009 09:03:50 -0700 Subject: [PATCH] * move win32 fixes --- artnet/network.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/artnet/network.c b/artnet/network.c index 535f1e5..76e842c 100644 --- a/artnet/network.c +++ b/artnet/network.c @@ -27,6 +27,9 @@ #include #else typedef int socklen_t; +#include +#include +#include #endif #include @@ -370,7 +373,9 @@ int artnet_net_init(node n, const char *preferred_ip) { printf(" bcast: %s\n" , inet_ntoa(ift->bcast_addr.sin_addr)); printf(" hwaddr: "); for (i = 0; i < ARTNET_MAC_SIZE; i++) { - printf("%hhx:", ift->hw_addr[i]); + if (i) + printf(":"); + printf("%02x", ift->hw_addr[i]); } printf("\n"); } @@ -433,7 +438,8 @@ int artnet_net_start(node n) { #ifdef WIN32 // check winsock version WSADATA wsaData; - if (WSAStartup(MAKEWORD(2, 2), &wsaData); != 0) + WORD wVersionRequested = MAKEWORD(2, 2); + if (WSAStartup(wVersionRequested, &wsaData); != 0) return (-1); if (wsaData.wVersion != wVersionRequested) return (-2); @@ -483,15 +489,17 @@ int artnet_net_start(node n) { if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &true_flag, sizeof(true_flag)) < 0) { - artnet_error("Set reuse failed", artnet_net_last_error()); - artnet_net_close(sock); - return ARTNET_ENET; + artnet_error("Set reuse failed", artnet_net_last_error()); + artnet_net_close(sock); + return ARTNET_ENET; } - if (SOCKET_ERROR == ioctlsocket(n->sd, FIONBIO, &true_flag)) { - artnet_error("ioctlsocket", artnet_net_last_error()); - artnet_net_close(sock); - return ARTNET_ENET; + if (SOCKET_ERROR == + ioctlsocket(sock, FIONBIO, (unsigned long) &true_flag)) { + + artnet_error("ioctlsocket", artnet_net_last_error()); + artnet_net_close(sock); + return ARTNET_ENET; } #endif @@ -653,8 +661,8 @@ int artnet_net_close(int sock) { artnet_error(artnet_net_last_error()); return ARTNET_ENET; } - return ARTNET_EOK; #endif + return ARTNET_EOK; }