version 1.15.2.2, 2008/01/02 21:07:59
|
version 1.19.2.1, 2006/07/27 23:11:52
|
|
|
#ifndef Pegasus_Socket_h | #ifndef Pegasus_Socket_h |
#define Pegasus_Socket_h | #define Pegasus_Socket_h |
| |
#include <Pegasus/Common/Config.h> |
|
#include <Pegasus/Common/IPC.h> |
|
#ifdef PEGASUS_OS_TYPE_WINDOWS |
|
#include <windows.h> |
|
# ifndef _WINSOCKAPI_ |
|
# include <winsock2.h> |
|
# endif |
|
#else |
|
# include <cctype> | # include <cctype> |
#ifndef PEGASUS_OS_OS400 |
#include <Pegasus/Common/Network.h> |
//# include <unistd.h> |
#include <Pegasus/Common/Config.h> |
#else |
#include <Pegasus/Common/Linkage.h> |
|
|
|
#ifdef PEGASUS_OS_OS400 |
# include <Pegasus/Common/OS400ConvertChar.h> | # include <Pegasus/Common/OS400ConvertChar.h> |
# include <unistd.cleinc> |
|
#endif | #endif |
|
|
#ifdef PEGASUS_OS_ZOS | #ifdef PEGASUS_OS_ZOS |
# include <string.h> // added by rk for memcpy | # include <string.h> // added by rk for memcpy |
#endif | #endif |
# include <cstdlib> |
|
# include <errno.h> |
|
# include <fcntl.h> |
|
# include <netdb.h> |
|
# include <netinet/in.h> |
|
# include <arpa/inet.h> |
|
# include <sys/socket.h> |
|
#endif |
|
#include <Pegasus/Common/Linkage.h> |
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
#ifndef PEGASUS_SOCKET |
class Socket |
#define PEGASUS_SOCKET int |
|
#endif |
|
|
|
#ifndef PEGASUS_INVALID_SOCKET |
|
#define PEGASUS_INVALID_SOCKET -1 |
|
#endif |
|
|
|
class PEGASUS_COMMON_LINKAGE Socket |
|
{ | { |
public: | public: |
| |
/** |
static Sint32 read(SocketHandle socket, void* ptr, Uint32 size); |
Connects the specified socket to the specified address. If the socket |
|
is non-blocking, the connect attempt will time out after the specified |
|
interval. |
|
|
|
@param socket The socket to connect. |
|
@param address The address to which to connect the socket |
|
@param addressLength The length of the sockaddr buffer in which the |
|
address is specified. |
|
@param timeoutMilliseconds The number of milliseconds after which the |
|
connect attempt should time out, if the socket is non-blocking. |
|
@return True if the connect attempt is successful, false otherwise. |
|
*/ |
|
static Boolean timedConnect( |
|
PEGASUS_SOCKET socket, |
|
sockaddr* address, |
|
int addressLength, |
|
Uint32 timeoutMilliseconds); |
|
|
|
static Sint32 read(PEGASUS_SOCKET socket, void* ptr, Uint32 size); |
|
| |
static Sint32 write(PEGASUS_SOCKET socket, const void* ptr, Uint32 size); |
static Sint32 write(SocketHandle socket, const void* ptr, Uint32 size); |
| |
static Sint32 timedWrite(PEGASUS_SOCKET socket, |
static Sint32 timedWrite(SocketHandle socket, |
const void* ptr, | const void* ptr, |
Uint32 size, | Uint32 size, |
Uint32 socketWriteTimeout); | Uint32 socketWriteTimeout); |
| |
static void close(PEGASUS_SOCKET socket); |
static void close(SocketHandle socket); |
| |
static void disableBlocking(PEGASUS_SOCKET socket); |
static void enableBlocking(SocketHandle socket); |
| |
static void initializeInterface(void); |
static void disableBlocking(SocketHandle socket); |
static void uninitializeInterface(void); |
|
| |
|
static void initializeInterface(); |
| |
private: |
static void uninitializeInterface(); |
| |
Socket() { } |
private: |
|
Socket(); |
}; | }; |
| |
|
|
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
#endif /* Pegasus_Socket_h */ | #endif /* Pegasus_Socket_h */ |