tweaks for Windows cmake build
This commit is contained in:
@@ -25,20 +25,19 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <inttypes.h>
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#if defined(_WIN32)
|
||||
#include <WinSock2.h>
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#include <WinSock2.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "libzt.h"
|
||||
@@ -71,18 +70,22 @@ int main(int argc, char **argv)
|
||||
uint64_t nodeId = zts_get_node_id();
|
||||
DEBUG_TEST("I am %llx", nodeId);
|
||||
|
||||
if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0)
|
||||
if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
|
||||
DEBUG_ERROR("error creating ZeroTier socket");
|
||||
}
|
||||
|
||||
if ((err = zts_bind(sockfd, (struct sockaddr *)&in6, sizeof(struct sockaddr_in6)) < 0))
|
||||
if ((err = zts_bind(sockfd, (struct sockaddr *)&in6, sizeof(struct sockaddr_in6)) < 0)) {
|
||||
DEBUG_ERROR("error binding to interface (%d)", err);
|
||||
}
|
||||
|
||||
if ((err = zts_listen(sockfd, 100)) < 0)
|
||||
if ((err = zts_listen(sockfd, 100)) < 0) {
|
||||
DEBUG_ERROR("error placing socket in LISTENING state (%d)", err);
|
||||
}
|
||||
|
||||
socklen_t client_addrlen = sizeof(sockaddr_in6);
|
||||
if ((accfd = zts_accept(sockfd, (struct sockaddr *)&acc_in6, &client_addrlen)) < 0)
|
||||
if ((accfd = zts_accept(sockfd, (struct sockaddr *)&acc_in6, &client_addrlen)) < 0) {
|
||||
DEBUG_ERROR("error accepting connection (%d)", err);
|
||||
}
|
||||
|
||||
socklen_t peer_addrlen = sizeof(struct sockaddr_storage);
|
||||
zts_getpeername(accfd, (struct sockaddr*)&acc_in6, &peer_addrlen);
|
||||
|
||||
Reference in New Issue
Block a user