#include <AsyncSocket.h>
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. | |
CIoTimeoutManager * | getTimeoutManager () |
Returns the library's #CIoTimeoutManager for your own use, saving creating another one. |
|
Returns the library's #CIoTimeoutManager for your own use, saving creating another one. Not valid until initialise() has been called. |
|
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.
|
|
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. |
|
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. |
|
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. |