Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

OW32::CAsyncSocketLib Class Reference

Asynchronous socket library initialisation/termination. More...

#include <AsyncSocket.h>

List of all members.

Static Public Member Functions

bool initialise (AsyncIoType model, HINSTANCE hInstance=NULL, WORD wSocketsVersion=MAKEWORD(0, 0), HANDLE hCompletionPort=NULL)
 Once per process call to initialise the asynchronous sockets library.
bool terminate ()
 Once per process call to terminate the asynchronous sockets library.
bool initialiseThread ()
 Called from each thread that can handle async I/O via windows messages.
bool terminateThread ()
 Called once per message thread to terminate the asynchronous sockets library.
CIoTimeoutManagergetTimeoutManager ()
 Returns the library's #CIoTimeoutManager for your own use, saving creating another one.


Detailed Description

Asynchronous socket library initialisation/termination.


Member Function Documentation

CIoTimeoutManager* OW32::CAsyncSocketLib::getTimeoutManager  )  [static]
 

Returns the library's #CIoTimeoutManager for your own use, saving creating another one.

Not valid until initialise() has been called.

bool OW32::CAsyncSocketLib::initialise AsyncIoType  model,
HINSTANCE  hInstance = NULL,
WORD  wSocketsVersion = MAKEWORD(0, 0),
HANDLE  hCompletionPort = NULL
[static]
 

Once per process call to initialise the asynchronous sockets library.

This function may be called multiple times as the associated data is reference counted. Multiple calls to this function must be balanced with calls to terminate. This function is thread safe.

Parameters:
model The global IO model
hInstance The module handle. If NULL, GetModuleHandle will be called.
wSocketsVersion If not MAKEWORD(0,0) (the default), will try to start sockets at the requested version level, and verify the version returned. In addition, terminate() will call WSACleanup.
hCompletionPort Completion port (required for timeouts) if using IOCP

bool OW32::CAsyncSocketLib::initialiseThread  )  [static]
 

Called from each thread that can handle async I/O via windows messages.

You need to call this at least once from a thread with a message loop if you intend to use asynchronous connection, close notification or host name lookup. This must be called from the thread with the message loop. See caveats.

The created data is reference counted, and while multiple calls are unnecessary, they can be made, but need to be balanced with calls to terminateThread().

Caveats: (1) For asynchronous message based sockets (#CAsyncMessageSocket) you must call this for any thread that you will be associating such a socket with. If you do not, then no notifications will be received and ths socket will not function. (2) For blocking sockets (#CAsyncBlockingSocket), which are designed for testing primarily, there is no need to call this. (3) For I/O completion port associated sockets (#CAsyncIoCompletionSocket), this function is *largely* unnecessary. You need it for asynchronous connect()/shutdown() calls (not accept()) and for asynchronous host lookups. For each thread that you call this from, another "spare" thread is added to handle connection or close notifications. Each connect() call will associate with a random thread. You can use this for load balancing connect calls across multiple CPUs by creating one thread per CPU. There is no benefit to be gained from calling this multiple times. (4) For APC based sockets (#CAsyncAPCSocket) this must be called once per socket thread. The thread must periodically enter an alertable wait state, e.g. through a MsgWaitForMultipleObjects based message loop.

bool OW32::CAsyncSocketLib::terminate  )  [static]
 

Once per process call to terminate the asynchronous sockets library.

This function is thread safe.

All initialiseThread() calls must have been cleaned up (by calls to terminateThread()) before this function is called.

bool OW32::CAsyncSocketLib::terminateThread  )  [static]
 

Called once per message thread to terminate the asynchronous sockets library.

You *must* ensure that there are no existing socket objects that have been bound to a thread using asynchronous connect or selected for asynchronous shutdown.


The documentation for this class was generated from the following file:
Generated on Sun Jun 5 01:29:23 2005 for OW32 by  doxygen 1.3.9.1