diff --git a/src/osgPlugins/net/GNUmakefile b/src/osgPlugins/net/GNUmakefile index 7ae7d60f8..a8e1deadd 100644 --- a/src/osgPlugins/net/GNUmakefile +++ b/src/osgPlugins/net/GNUmakefile @@ -6,7 +6,7 @@ CXXFILES =\ sockinet.cpp\ sockstream.cpp\ -LIBS += $(OSG_LIBS) $(OTHER_LIBS) +LIBS += $(OSG_LIBS) $(OTHER_LIBS) $(SOCKET_LIBS) TARGET_BASENAME = net include $(TOPDIR)/Make/cygwin_plugin_def diff --git a/src/osgPlugins/net/sockinet.cpp b/src/osgPlugins/net/sockinet.cpp index 0d397db3d..7ad8eae7e 100644 --- a/src/osgPlugins/net/sockinet.cpp +++ b/src/osgPlugins/net/sockinet.cpp @@ -38,7 +38,7 @@ typedef int socklen_t; #endif -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) extern "C" { # include # include diff --git a/src/osgPlugins/net/sockinet.h b/src/osgPlugins/net/sockinet.h index f683c2465..35d3495cf 100644 --- a/src/osgPlugins/net/sockinet.h +++ b/src/osgPlugins/net/sockinet.h @@ -12,7 +12,8 @@ #define _SOCKINET_H #include "sockstream.h" -#ifndef WIN32 + +#if defined(__CYGWIN__) || !defined(WIN32) # include #endif // !WIN32 diff --git a/src/osgPlugins/net/sockstream.cpp b/src/osgPlugins/net/sockstream.cpp index 6fd57814d..41ff364b3 100644 --- a/src/osgPlugins/net/sockstream.cpp +++ b/src/osgPlugins/net/sockstream.cpp @@ -67,7 +67,7 @@ typedef int socklen_t; #endif -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) extern "C" { # include # include @@ -134,7 +134,7 @@ extern "C" { const char* sockerr::errstr () const { -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) return sys_errlist[err]; #else return 0; // TODO @@ -240,7 +240,7 @@ bool sockerr::benign () const case EWOULDBLOCK: // On FreeBSD (and probably on Linux too) // EAGAIN has the same value as EWOULDBLOCK -#if !defined( __sgi) && !defined(__linux__) && !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__APPLE__)) // LN +#if !defined(__CYGWIN__) && !defined( __sgi) && !defined(__linux__) && !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__APPLE__)) // LN case EAGAIN: #endif return true; @@ -263,7 +263,7 @@ sockbuf::sockbuf (const sockbuf::sockdesc& sd) sockbuf::sockbuf (int domain, sockbuf::type st, int proto) : rep (0) { -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) WORD version = MAKEWORD(1,1); WSADATA wsaData; WSAStartup(version, &wsaData); @@ -271,7 +271,7 @@ sockbuf::sockbuf (int domain, sockbuf::type st, int proto) SOCKET soc = ::socket (domain, st, proto); if (soc == SOCKET_ERROR) -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) throw sockerr (errno, "sockbuf::sockbuf"); #else throw sockerr(WSAGetLastError(), "sockbuf::sockbuf"); @@ -319,14 +319,14 @@ sockbuf::~sockbuf () if (--rep->cnt == 0) { delete [] pbase (); delete [] eback (); -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) int c = close (rep->sock); #else int c = closesocket(rep->sock); #endif delete rep; if (c == SOCKET_ERROR) -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) throw sockerr (errno, "sockbuf::~sockbuf", sockname.c_str()); #else throw sockerr(WSAGetLastError(), "sockbuf::~sockbuf", sockname.c_str()); @@ -899,7 +899,7 @@ bool sockbuf::atmark () const // return true, if the read pointer for socket points to an // out of band data { -#ifndef WIN32 +#if !(defined(__CYGWIN__) || defined(WIN32)) int arg; if (::ioctl (rep->sock, SIOCATMARK, &arg) == -1) throw sockerr (errno, "sockbuf::atmark", sockname.c_str()); @@ -911,7 +911,7 @@ bool sockbuf::atmark () const return arg!=0; } -#ifndef WIN32 +#if !(defined(__CYGWIN__) || defined(WIN32)) int sockbuf::pgrp () const // return the process group id that would receive SIGIO and SIGURG // signals @@ -953,7 +953,7 @@ long sockbuf::nread () const // the socket. { long arg; -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) if (::ioctl (rep->sock, FIONREAD, &arg) == -1) throw sockerr (errno, "sockbuf::nread", sockname.c_str()); #else @@ -976,7 +976,7 @@ void sockbuf::nbio (bool set) const // The read or write operation will result throwing a sockerr // exception with errno set to EWOULDBLOCK. { -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) int arg = set; if (::ioctl (rep->sock, FIONBIO, &arg) == -1) throw sockerr (errno, "sockbuf::nbio", sockname.c_str()); @@ -987,7 +987,7 @@ void sockbuf::nbio (bool set) const #endif // !WIN32 } -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) void sockbuf::async (bool set) const // if set is true, set socket for asynchronous io. If any io is // possible on the socket, the process will get SIGIO diff --git a/src/osgPlugins/net/sockstream.h b/src/osgPlugins/net/sockstream.h index c2df018d2..ba5c70d0a 100644 --- a/src/osgPlugins/net/sockstream.h +++ b/src/osgPlugins/net/sockstream.h @@ -40,7 +40,7 @@ #include #include //#include -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) # include # include # include @@ -58,7 +58,7 @@ typedef int socklen_t; using namespace std; -#ifdef __linux__ +#if defined(__linux__) || defined(__CYGWIN__) # define MSG_MAXIOVLEN 16 #endif // __linux__ @@ -313,8 +313,10 @@ class sockbuf: public streambuf inline void setname(const string &name); inline const string& getname(); -#ifndef WIN32 +#if defined(__CYGWIN__) || !defined(WIN32) void async(bool set=true) const; +#endif +#if !defined(__CYGWIN__) || !defined(WIN32) int pgrp() const; int pgrp(int new_pgrp) const; void closeonexec(bool set=true) const;