Fixes to the .net plugin for Cygwin, submitted by Norman Vine

This commit is contained in:
Don BURNS
2004-11-09 07:34:28 +00:00
parent 744315b65c
commit ec319e663f
5 changed files with 21 additions and 18 deletions

View File

@@ -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

View File

@@ -38,7 +38,7 @@
typedef int socklen_t;
#endif
#ifndef WIN32
#if defined(__CYGWIN__) || !defined(WIN32)
extern "C" {
# include <netdb.h>
# include <sys/time.h>

View File

@@ -12,7 +12,8 @@
#define _SOCKINET_H
#include "sockstream.h"
#ifndef WIN32
#if defined(__CYGWIN__) || !defined(WIN32)
# include <netinet/in.h>
#endif // !WIN32

View File

@@ -67,7 +67,7 @@
typedef int socklen_t;
#endif
#ifndef WIN32
#if defined(__CYGWIN__) || !defined(WIN32)
extern "C" {
# include <sys/time.h>
# include <sys/socket.h>
@@ -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

View File

@@ -40,7 +40,7 @@
#include <string.h>
#include <string>
//#include <cstdio>
#ifndef WIN32
#if defined(__CYGWIN__) || !defined(WIN32)
# include <sys/types.h>
# include <sys/uio.h>
# include <sys/socket.h>
@@ -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;