Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

lfc::win32PAL::sockets Namespace Reference

win32 sockets PAL. More...


Typedefs

typedef SOCKET Handle
 win32 socket type. More...


Enumerations

enum  ErrorCodes {
  errOk, errGeneric, errInitError, errConnectionClosed,
  errUnbound, errNotListening, errBadAddress
}

Functions

int init ()
 initializes the environment. it _MUST_ be called _before_ any other sockets function. More...

int cleanup ()
 cleans up the environment. it _MUST_ be called after there's no more need for sockets. More...

int open (Handle &handle, int pf, int type)
 creates a socket. More...

int close (Handle handle)
 closes the socket. More...

int connect (Handle handle, const char *to, int pf, u_short port)
 establish a connection with a peer. More...

int send (Handle handle, const char *buffer, long len, int flags, long &bytesSent)
 sends data on a connected socket. More...

int sendTo (Handle handle, const char *buffer, long len, int flags, const char *to, int pf, u_short port, long &bytesSent)
 sends data to a specific destination ( most likely to be used in combination with connectionless protocols ). More...

int recv (Handle handle, char *buffer, long len, int flags, long &bytesReceived)
 tries to receive data from a connected socket. More...

int recvFrom (Handle handle, char *buffer, long len, int flags, char *from, int pf, u_short port, long &bytesReceived)
 receives a datagram and stores the source address. More...

int bind (Handle handle, int pf, u_short port)
 associates a local address with a socket. More...

int listen (Handle handle, int backlog=SOMAXCONN)
 puts the socket into listening state for incoming connections. More...

int accept (Handle &newHandle, Handle handle)
 accept a connection on a socket. More...

int setBlocking (Handle handle, bool blocking)
 control the mode of a socket. More...

int getServicePort (const char *service, u_short &port)
int flush (Handle handle)
 flush socket buffers. More...

const char * message (int index)
 translates error codes to human readable error messages. More...


Variables

const int MAX_ERROR_CODE = 6
const char * messagesTable [MAX_ERROR_CODE+1]
const int pfINET = AF_INET
 the network protocol family categories. More...

const int pfUNIX = AF_UNIX
 the network protocol family categories. More...

const int pfIPX = AF_IPX
 the network protocol family categories. More...

const int stSTREAM = SOCK_STREAM
 connection oriented and conectionless socket types. More...

const int stDGRAM = SOCK_DGRAM
 connection oriented and conectionless socket types. More...

const int flagPEEK = MSG_PEEK
 flags for use with send()/sendto()/recv()/recvfrom(). More...

const int flagOOB = MSG_OOB
 flags for use with send()/sendto()/recv()/recvfrom(). More...

const Handle NULL_HANDLE = INVALID_SOCKET
 a handle value designating an invalid handle. More...


Detailed Description

win32 sockets PAL.

Typedef Documentation

typedef SOCKET lfc::win32PAL::sockets::Handle
 

win32 socket type.


Enumeration Type Documentation

enum lfc::win32PAL::sockets::ErrorCodes
 

Enumeration values:
errOk 
errGeneric 
errInitError 
errConnectionClosed 
errUnbound 
errNotListening 
errBadAddress 


Function Documentation

int init   [inline]
 

initializes the environment. it _MUST_ be called _before_ any other sockets function.

Returns:
error code ( 0 == no errors )

int cleanup   [inline]
 

cleans up the environment. it _MUST_ be called after there's no more need for sockets.

Returns:
error code ( 0 == no errors )

int open Handle   handle,
int    pf,
int    type
[inline]
 

creates a socket.

Parameters:
handle  contains a valid socket handle if the operation succeeds
pf  protocol family. see the ProtocolFamily enum for allowed values.
type  the socket type. see the SocketType enum for allowed values.
Returns:
error code ( 0 == no errors )

int close Handle    handle [inline]
 

closes the socket.

Parameters:
handle  a handle to the socket to close
Returns:
error code ( 0 == no errors )

int connect Handle    handle,
const char *    to,
int    pf,
u_short    port
[inline]
 

establish a connection with a peer.

Parameters:
handle  a handle to the socket to connect
to  a C-style string containing either a hostname or an IP address
pf  the protocol family to be used for the connection; see the ProtocolFamily enum
port  the peer port you wish to connect to
Returns:
error code ( 0 == no errors )

int send Handle    handle,
const char *    buffer,
long    len,
int    flags,
long &    bytesSent
[inline]
 

sends data on a connected socket.

Parameters:
handle  a handle to the socket to send
buffer  pointer to the buffer containing the data to be sent
len  number of bytes to send from the buffer
flags  see the Flag enum. flagPEEK gets len bytes into the buffer but doesn't remove them from the input queue.
bytesSent  the number of bytes that send() managed to actually send
Returns:
error code ( 0 == no errors )

int sendTo Handle    handle,
const char *    buffer,
long    len,
int    flags,
const char *    to,
int    pf,
u_short    port,
long &    bytesSent
[inline]
 

sends data to a specific destination ( most likely to be used in combination with connectionless protocols ).

Parameters:
handle  a handle to the socket to send
buffer  pointer to the buffer containing the data to be sent
len  number of bytes to send from the buffer
flags  see the Flag enum. flagPEEK gets len bytes into the buffer but doesn't remove them from the input queue.
to  a C-style string containing either a hostname or an IP address
pf  the protocol family to be used; see the ProtocolFamily enum
port  the peer port you wish to connect to
bytesSent  the number of bytes that sendto() managed to actually send
Returns:
error code ( 0 == no errors )

int recv Handle    handle,
char *    buffer,
long    len,
int    flags,
long &    bytesReceived
[inline]
 

tries to receive data from a connected socket.

Parameters:
handle  a handle to the socket to receive
buffer  pointer to the buffer to hold the received data into
len  number of bytes to receive into the buffer
flags  see the Flag enum. flagPEEK gets len bytes into the buffer but doesn't remove them from the input queue.
Returns:
error code ( 0 == no errors )

int recvFrom Handle    handle,
char *    buffer,
long    len,
int    flags,
char *    from,
int    pf,
u_short    port,
long &    bytesReceived
[inline]
 

receives a datagram and stores the source address.

Parameters:
handle  a handle to the socket to receive
buffer  pointer to the buffer to hold the received data into
len  number of bytes to receive into the buffer
flags  see the Flag enum. flagPEEK gets len bytes into the buffer but doesn't remove them from the input queue.
from  a C-style string containing an IP address; filled after execution
pf  the protocol family to be used; see the ProtocolFamily enum
port  the peer port you wish to connect to
Returns:
error code ( 0 == no errors )

int bind Handle    handle,
int    pf,
u_short    port
[inline]
 

associates a local address with a socket.

Parameters:
handle  a handle to the socket to connect
pf  the protocol family that the desired to be bound socket should use
port  the port to bind the socket represented by handle to
Returns:
error code ( 0 == no errors )

int listen Handle    handle,
int    backlog = SOMAXCONN
[inline]
 

puts the socket into listening state for incoming connections.

Parameters:
handle  a handle to the socket to listen
backlog  the maximum length to which the queue of pending connections may grow
Returns:
error code ( 0 == no errors )

int accept Handle   newHandle,
Handle    handle
[inline]
 

accept a connection on a socket.

Parameters:
newHandle  will contain a handle to a new socket if accept() succeeds; won't be modified otherwise
handle  the socket that accepts connections
Returns:
error code ( 0 == no errors )

int setBlocking Handle    handle,
bool    blocking
[inline]
 

control the mode of a socket.

Parameters:
handle  a handle to the socket.
blocking  true, for blocking mode, false for non-blocking mode
Returns:
error code ( 0 == no errors )

int getServicePort const char *    service,
u_short &    port
[inline]
 

Parameters:
service  service name
port  return the port asociated with service
Returns:
error code ( 0 == no errors )

int flush Handle    handle [inline]
 

flush socket buffers.

Parameters:
handle  an open socket handle
Returns:
error code ( 0 == no errors )
Todo:
fix this!

const char* message int    index [inline]
 

translates error codes to human readable error messages.

Parameters:
index  message index (return code from other pal functions)


Variable Documentation

const int lfc::win32PAL::sockets::MAX_ERROR_CODE = 6
 

const char * lfc::win32PAL::sockets::messagesTable
 

Initial value:

{
    "win32PAL::sockets -- No error (ok)",
    "win32PAL::sockets -- Generic socket error",
    "win32PAL::sockets -- Environment not initialized",
    "win32PAL::sockets -- Connection has been closed",
    "win32PAL::sockets -- Unbound socket",
    "win32PAL::sockets -- Socket should be listening",
    "win32PAL::sockets -- Invalid hostname/IP address",
}

const int lfc::win32PAL::sockets::pfINET = AF_INET
 

the network protocol family categories.

const int lfc::win32PAL::sockets::pfUNIX = AF_UNIX
 

the network protocol family categories.

const int lfc::win32PAL::sockets::pfIPX = AF_IPX
 

the network protocol family categories.

const int lfc::win32PAL::sockets::stSTREAM = SOCK_STREAM
 

connection oriented and conectionless socket types.

const int lfc::win32PAL::sockets::stDGRAM = SOCK_DGRAM
 

connection oriented and conectionless socket types.

const int lfc::win32PAL::sockets::flagPEEK = MSG_PEEK
 

flags for use with send()/sendto()/recv()/recvfrom().

const int lfc::win32PAL::sockets::flagOOB = MSG_OOB
 

flags for use with send()/sendto()/recv()/recvfrom().

const Handle lfc::win32PAL::sockets::NULL_HANDLE = INVALID_SOCKET
 

a handle value designating an invalid handle.


Generated on Sat Jan 26 00:35:17 2002 for LFC2 PAL by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001