Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Cabal::Net_WSA Class Reference

WSA specific basic functionality wrapper. More...

#include <cabal_os_wsa.h>

Inheritance diagram for Cabal::Net_WSA:

Inheritance graph
[legend]
Collaboration diagram for Cabal::Net_WSA:

Collaboration graph
[legend]
List of all members.

Static Public Member Functions

bool init () throw (InitError)
bool exit () throw (DataIncompleteError)
RawSocket createTCPSocket ()
 Create a socket with cabal properties.

RawSocket createUDPSocket ()
int closeSocket (RawSocket s)
 Closes a underlying OS system socket resource.

int bind (const RawSocket s, const SockAddrInet &addr)
 Binds a socket to a local address and/or port.

bool connect (const RawSocket s, const SockAddrInet &addr)
 Connect a socket with a remote address.

bool listen (const RawSocket s, const int incomingMax)
 Prepare a socket to receive connections.

RawSocket accept (const RawSocket s, SockAddrInet *in)
 Accepts incoming connections.

void initSockAddr (SockAddrInet &attr)
 Address initializer.

void initSockAddr (SockAddrInet &attr, const char *ip)
void initSockAddr (SockAddrInet &attr, const char *ip, const NetPort port)
void initSockAddr (SockAddrInet &attr, const NetAddr address, const NetPort port)
bool SockAddrIsZero (const SockAddrInet &addr)
 Socket Address related functions.

void SockAddrSetPort (SockAddrInet &addr, NetPort port)
bool SockAddrIsSame (const SockAddrInet &addr, const SockAddrInet &addr1)
NetPort SockAddrGetPort (const SockAddrInet &addr)
bool getHostList (const std::string &name, std::string &real_name, char *real_ip, NetAddr *other_addrs, int na_count)
 Return a threadsafe value for gethostbyname.

bool addrToString (const SockAddrInet &addr, char *dest)
 Returns a string representation of a given address.

bool stringToAddr (const char *source, SockAddrInet &addr)
 Creates Socket address from a given string representation If the source string is not in any convertible ip address representation, the function return false.

bool isAddressString (const char *source)
 Returns true if the given string is a valid IP address representation.

int errorCode ()
 Return last OS dependant error code.

std::string errorDescription (const int osCode)
 Returns the error description of a given code.

void resetError ()
 Clears OS level error code.

RawSocket dup (RawSocket s)
 Duplicates an handle.

bool inProgress ()
 True if current low level error means "operation in progress".

bool errorAgain ()
 True if current low level error means "try again".

bool errorAgain (int error)
 True if parameter is an error code meaning "try again".

bool errorPipe ()
 True if current low level error means "broken pipe".

void setNonBlocking (RawSocket s)
 System specific way to set socket as nonblocking.

void setBlocking (RawSocket s)
 System specific way to set socket as blocking.

void setTCPDefaults (const RawSocket s)
 Sets default TCP attributes on the socket.

bool validSocket (const RawSocket s)
 True if socket is a valid socket (not a return error code).

void invalidate (RawSocket &s)
 Make s to become an "invalid socket" marker.

int getSocketOption (const RawSocket s, const int level, int &iErrval)
 System specific way to set a socket file control option.

int send (const RawSocket s, const void *buffer, const int len, const int params=0)
 System specific send call.

int recv (const RawSocket s, void *buffer, const int len, const int params=0)
 System specific receive call.

int sendto (const RawSocket s, const void *buffer, const int len, const int params, const SockAddrInet *remote, const int remsize)
 System specific send to address call.

int recvfrom (const RawSocket s, void *buffer, const int len, const int params, SockAddrInet *remote, int *remsize)
 System specific receive from address call.

void shutdown (const RawSocket s)
 System specific way to close a TCP connection cleanly.

void sleep (const int msecs)
 Used to sleep.

NetPort hostToNetPort (const NetPort data)
 Host to network byte swapping.

NetAddr hostToNetAddr (const NetAddr data)
NetPort netToHostPort (const NetPort data)
NetAddr netToHostAddr (const NetAddr data)
MSECS timeOfDay ()
 Returns the time of day in milliseconds since midnight.


Detailed Description

WSA specific basic functionality wrapper.

Definition at line 58 of file cabal_os_wsa.h.


Member Function Documentation

RawSocket Cabal::Net_WSA::accept const RawSocket  s,
SockAddrInet *  in
[inline, static]
 

Accepts incoming connections.

Returns:
on failure an invalid raw socket, on success a valid one.

Reimplemented from Cabal::NetBase.

Definition at line 92 of file cabal_os_wsa.h.

bool Cabal::Net_WSA::addrToString const SockAddrInet &  addr,
char *  dest
[static]
 

Returns a string representation of a given address.

Puts into dest, that must be long CABAL_MAX_IP_SIZE to accept the returned data. On error, returns false; this may be because addr is not valid, (i.e. it has an unknown address family).

Note:
the destination string will not contain any indicator of the IP port stored in addr.
Usually, it returns true.
Parameters:
addr the address to be converted
dest the destination
Returns:
true on success, false on error.

Reimplemented from Cabal::NetBase.

Definition at line 92 of file ltlib/cabal_os_wsa.cpp.

Referenced by getHostList().

int Cabal::Net_WSA::bind const RawSocket  s,
const SockAddrInet &  addr
[inline, static]
 

Binds a socket to a local address and/or port.

returns false on failure.

Reimplemented from Cabal::NetBase.

Definition at line 73 of file cabal_os_wsa.h.

void Cabal::Net_WSA::setTCPDefaults const RawSocket  s  )  [inline, static]
 

Sets default TCP attributes on the socket.

For Cabal, they are keep alive and reuse address options.

Reimplemented from Cabal::NetBase.

Definition at line 203 of file cabal_os_wsa.h.

void Cabal::Net_WSA::sleep const int  msecs  )  [inline, static]
 

Used to sleep.

Really, this function should be used in other libraries, but it turns tobe useful for portable tests.

Reimplemented from Cabal::NetBase.

Definition at line 258 of file cabal_os_wsa.h.

bool Cabal::Net_WSA::stringToAddr const char *  source,
SockAddrInet &  addr
[inline, static]
 

Creates Socket address from a given string representation If the source string is not in any convertible ip address representation, the function return false.

Note:
the source string may not contain ports specification.
Parameters:
addr the
dest the destination socket address.
Returns:
true on success false on error.

Reimplemented from Cabal::NetBase.

Definition at line 143 of file cabal_os_wsa.h.

Referenced by isAddressString().

MSECS Cabal::Net_WSA::timeOfDay  )  [static]
 

Returns the time of day in milliseconds since midnight.

Used to temporize sendings.

Reimplemented from Cabal::NetBase.

Definition at line 125 of file ltlib/cabal_os_wsa.cpp.


The documentation for this class was generated from the following files:
Generated on Sat Apr 10 17:41:49 2004 for Cabal by doxygen 1.3.5