+
+//
+// Common cross platform services
+//
+#if defined(WIN32)
+# include <winsock2.h>
+# define dnssd_InvalidSocket INVALID_SOCKET
+# define dnssd_EWOULDBLOCK WSAEWOULDBLOCK
+# define dnssd_EINTR WSAEINTR
+# define MSG_WAITALL 0
+# define dnssd_sock_t SOCKET
+# define dnssd_sockbuf_t
+# define dnssd_close(sock) closesocket(sock)
+# define dnssd_errno() WSAGetLastError()
+# define ssize_t int
+# define getpid _getpid
+#else
+# include <sys/types.h>
+# include <unistd.h>
+# include <sys/un.h>
+# include <string.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <sys/stat.h>
+# include <sys/socket.h>
+# include <netinet/in.h>
+# define dnssd_InvalidSocket -1
+# define dnssd_EWOULDBLOCK EWOULDBLOCK
+# define dnssd_EINTR EINTR
+# define dnssd_EPIPE EPIPE
+# define dnssd_sock_t int
+# define dnssd_close(sock) close(sock)
+# define dnssd_errno() errno
+#endif
+
+#if defined(USE_TCP_LOOPBACK)
+# define AF_DNSSD AF_INET
+# define MDNS_TCP_SERVERADDR "127.0.0.1"
+# define MDNS_TCP_SERVERPORT 5354
+# define LISTENQ 5
+# define dnssd_sockaddr_t struct sockaddr_in
+#else
+# define AF_DNSSD AF_LOCAL
+# define MDNS_UDS_SERVERPATH "/var/run/mDNSResponder"
+# define LISTENQ 100
+ // longest legal control path length
+# define MAX_CTLPATH 256
+# define dnssd_sockaddr_t struct sockaddr_un
+#endif
+
+
+//#define UDSDEBUG // verbose debug output
+
+// Compatibility workaround
+#ifndef AF_LOCAL
+#define AF_LOCAL AF_UNIX
+#endif