version 1.11, 2003/08/14 22:01:27
|
version 1.21.2.1, 2006/02/10 16:09:38
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) | // Author: Mike Brasher (mbrasher@bmc.com) |
// | // |
// Modified By: |
// Modified By: Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#2513 |
|
// David Dillard, Symantec Corp., (david_dillard@symantec.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
static Uint32 _socketInterfaceRefCount = 0; | static Uint32 _socketInterfaceRefCount = 0; |
| |
Sint32 Socket::read(Sint32 socket, void* ptr, Uint32 size) |
Sint32 Socket::read(PEGASUS_SOCKET socket, void* ptr, Uint32 size) |
{ | { |
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |
return ::recv(socket, (char*)ptr, size, 0); | return ::recv(socket, (char*)ptr, size, 0); |
#elif defined(PEGASUS_OS_ZOS) |
|
int i=::read(socket, (char*)ptr, size); |
|
__atoe_l((char *)ptr,size); |
|
return i; |
|
#else | #else |
|
#if defined (__GNUC__) && !defined(PEGASUS_OS_SOLARIS) && !defined(PEGASUS_OS_DARWIN) && !defined(PEGASUS_OS_LSB) |
#if defined (__GNUC__) |
|
int ccode = TEMP_FAILURE_RETRY(::read(socket, (char*)ptr, size)); | int ccode = TEMP_FAILURE_RETRY(::read(socket, (char*)ptr, size)); |
return ccode; | return ccode; |
#else | #else |
|
|
#endif | #endif |
} | } |
| |
Sint32 Socket::write(Sint32 socket, const void* ptr, Uint32 size) |
Sint32 Socket::write(PEGASUS_SOCKET socket, const void* ptr, Uint32 size) |
{ | { |
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |
return ::send(socket, (const char*)ptr, size, 0); | return ::send(socket, (const char*)ptr, size, 0); |
#elif defined(PEGASUS_OS_ZOS) |
|
char * ptr2 = (char *)malloc(size); |
|
int i; |
|
memcpy(ptr2,ptr,size); |
|
__etoa_l(ptr2,size); |
|
i = ::write(socket, ptr2, size); |
|
free(ptr2); |
|
return i; |
|
#else | #else |
#if (__GNUC__) |
#if (__GNUC__) && !defined(PEGASUS_OS_SOLARIS) && !defined(PEGASUS_OS_DARWIN) && !defined(PEGASUS_OS_LSB) |
int ccode = TEMP_FAILURE_RETRY(::write(socket, (char*)ptr, size)); | int ccode = TEMP_FAILURE_RETRY(::write(socket, (char*)ptr, size)); |
return ccode; | return ccode; |
#else | #else |
|
|
#endif | #endif |
} | } |
| |
void Socket::close(Sint32 socket) |
void Socket::close(PEGASUS_SOCKET socket) |
{ | { |
#ifdef PEGASUS_OS_TYPE_WINDOWS |
if(-1 != socket) |
closesocket(socket); |
|
#else |
|
#if (__GNUC__) |
|
TEMP_FAILURE_RETRY(::close(socket)); |
|
#else |
|
::close(socket); |
|
#endif |
|
#endif |
|
} |
|
|
|
int Socket::close2(Sint32 socket) |
|
{ | { |
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |
return closesocket(socket); |
if(!closesocket(socket)) socket=-1; |
#else | #else |
#if (__GNUC__) |
#if (__GNUC__) && !defined(PEGASUS_OS_SOLARIS) && !defined(PEGASUS_OS_DARWIN) && !defined(PEGASUS_OS_LSB) |
int ccode = TEMP_FAILURE_RETRY(::close(socket)); |
if(!TEMP_FAILURE_RETRY(::close(socket))) socket = -1; |
return ccode; |
|
#else | #else |
return ::close(socket); |
if(!::close(socket)) socket = -1; |
#endif | #endif |
#endif | #endif |
} | } |
|
} |
| |
|
void Socket::enableBlocking(PEGASUS_SOCKET socket) |
void Socket::enableBlocking(Sint32 socket) |
|
{ | { |
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |
unsigned long flag = 0; | unsigned long flag = 0; |
|
|
#endif | #endif |
} | } |
| |
int Socket::enableBlocking2(Sint32 socket) |
void Socket::disableBlocking(PEGASUS_SOCKET socket) |
{ |
|
#ifdef PEGASUS_OS_TYPE_WINDOWS |
|
unsigned long flag = 0; |
|
return ioctlsocket(socket, FIONBIO, &flag); |
|
#else |
|
int flags = fcntl(socket, F_GETFL, 0); |
|
flags &= ~O_NONBLOCK; |
|
return fcntl(socket, F_SETFL, flags); |
|
#endif |
|
} |
|
|
|
void Socket::disableBlocking(Sint32 socket) |
|
{ | { |
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |
unsigned long flag = 1; | unsigned long flag = 1; |
|
|
#endif | #endif |
} | } |
| |
int Socket::disableBlocking2(Sint32 socket) |
|
{ |
|
#ifdef PEGASUS_OS_TYPE_WINDOWS |
|
unsigned long flag = 1; |
|
return ioctlsocket(socket, FIONBIO, &flag); |
|
#else |
|
int flags = fcntl(socket, F_GETFL, 0); |
|
flags |= O_NONBLOCK; |
|
return fcntl(socket, F_SETFL, flags); |
|
#endif |
|
} |
|
|
|
void Socket::initializeInterface() | void Socket::initializeInterface() |
{ | { |
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |