/* * mzsocket: BSD/POSIX sockets library for mzscheme * Copyright (C) 2007 Dimitris Vyzovitis * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA */ #include "escheme.h" #if (defined(__WIN32__) || defined(WIN32) || defined(_WIN32)) #define WINDOWS #else #define UNIX #endif #if (MZSCHEME_VERSION_MAJOR >= 369) && (MZSCHEME_VERSION_MINOR >= 8) #define HAVE_TYPE_EQUALITY #endif #ifdef UNIX #include #include #include #include #include #include #include #include #include typedef int fd_t; typedef u_int16_t u16; typedef u_int32_t u32; #define ERRNO errno #define INVALID -1 #ifndef UNIX_PATH_MAX #define UNIX_PATH_MAX 108 #endif #else #include #include #define SHUT_RD SD_RECEIVE #define SHUT_WR SD_SEND #define SHUT_RDWR SD_BOTH typedef SOCKET fd_t; typedef unsigned __int16 u16; typedef unsigned __int32 u32; #define ERRNO (WSAGetLastError()) #define INVALID INVALID_SOCKET // errno translation (mostly cygwin) #define EINTR WSAEINTR #define EACCES WSAEACCES #define EAFNOSUPPORT WSAEAFNOSUPPORT #define EPFNOSUPPORT WSAEPFNOSUPPORT #define EPROTONOSUPPORT WSAEPROTONOSUPPORT #define ENOBUFS WSAENOBUFS #define EFAULT WSAEFAULT #define EADDRINUSE WSAEADDRINUSE #define EINVAL WSAEINVAL #define ENOTSOCK WSAENOTSOCK #define EOPNOTSUPP WSAEOPNOTSUPP #define EWOULDBLOCK WSAEWOULDBLOCK #define ECONNABORTED WSAECONNABORTED #define EMFILE WSAEMFILE #define ETIMEDOUT WSAETIMEDOUT #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT #define EALREADY WSAEALREADY #define ECONNREFUSED WSAECONNREFUSED #define EISCONN WSAEISCONN #define ENETUNREACH WSAENETUNREACH #define ECONNRESET WSAECONNRESET #define EDESTADDRREQ WSAEDESTADDRREQ #define EMSGSIZE WSAEMSGSIZE #define ENOTCONN WSAENOTCONN #define EPROTOTYPE WSAENOTCONN #define ENOPROTOOPT WSAENOPROTOOPT #define EINPROGRESS WSAEINPROGRESS #define EADDRNOTAVAIL WSAEADDRNOTAVAIL #define ENETDOWN WSAENETDOWN #define ENETRESET WSAENETRESET #define ESHUTDOWN WSAESHUTDOWN #define EHOSTDOWN WSAEHOSTDOWN #define EHOSTUNREACH WSAEHOSTUNREACH #define ENOMEM WSA_NOT_ENOUGH_MEMORY #define EBADF WSAENOTSOCK #define ENFILE -1 #define EPIPE -1 #endif #ifdef IPPROTO_IPV6 # define HAVE_IPV6 #endif #ifdef IPPROTO_RAW # define HAVE_RAW #endif