#include <asyncclientconnector.h>
Public Methods | |
void | handleException (GeneralException &e) |
Not currently used. More... | |
void | sendPacket (PacketBuffer *pPkt) |
Sends the packet. More... | |
void | sendPacket (PacketBuffer &pPkt) |
Sends the packet. More... | |
void | operator<< (PacketBuffer &) |
Sends the packet. More... | |
void | operator<< (PacketBuffer *) |
Sends the packet. More... | |
PacketMessage * | getMsg () |
Retrieves the next message from the message queue. More... | |
AsyncClientConnector (const char *pszHost, word wPort) | |
Constructs and connects to host. More... | |
~AsyncClientConnector () | |
Destroys and closes any connections. More... | |
const char * | getServer () |
Returns the server host name you assigned this client object. More... | |
const word | getPort () |
Returns the port you assigned this client object. More... | |
bool | isConnected () |
Returns if this client is connected or not. More... | |
ServerSocket * | getSocket () |
Returns the ServerSocket of this client object. More... | |
void | reconnect () |
Tries to reconnect to the server. More... | |
void | connect (const char *pszHost, const unsigned16 wPort) |
Stores server info passed in, and attempts to connect to the server. More... | |
void | connect () |
Connects to the server. More... | |
void | close () |
Closes the connection to the server. More... | |
bool | idle () |
You call this so AsyncClientConnector can check for incoming data. More... | |
Protected Methods | |
void | cleanup () |
Closes the connection without throwing any exeptions on errors during socket closer. Deletes the socket. More... | |
void | setNonBlocking (SOCKET sockfd) |
Protected Attributes | |
unsigned16 | m_wPort |
Port number of the server you wish to connect to. More... | |
CStr | m_strHost |
Host name of the server you wish to connect to. More... | |
ServerSocket * | m_pSocket |
Socket connected to the server. More... | |
PacketMessageQue | m_que |
Message que that contains any messages that have been parsed from read socket data. More... |
This is an asynchronis client class used so you can poll for incoming packets. If there are no packets available, your program will not block. If there is incoming data, it will be read and parsed into packets and posted to the message queue if possible.
You would use this class if you didn't want to use threads. Note however, since this class uses the PacketMessageQue class, you must still compile using threading options.
|
Constructs and connects to host. Constructs a AsyncClientConnector object and connects to host pointed to by pszHost on port pointed to by wPort.
|
|
Destroys and closes any connections.
|
|
Closes the connection without throwing any exeptions on errors during socket closer. Deletes the socket.
|
|
Closes the connection to the server.
|
|
Connects to the server. Attempts to connect to the server. Once connected, the socket is put into non-blocking mode.
|
|
Stores server info passed in, and attempts to connect to the server. Stores the information you pass in, and then tries to connect to that server.
|
|
Retrieves the next message from the message queue. Gets the next message, and removes it from the message queue.
|
|
Returns the port you assigned this client object.
|
|
Returns the server host name you assigned this client object.
|
|
Returns the ServerSocket of this client object.
|
|
Not currently used.
|
|
You call this so AsyncClientConnector can check for incoming data. You call idle as often as you are able to. When idle is called, it will check for incoming data. If there is data on the connected socket, it will be read, and parsed into packets. If the connection is closed gracefully on the other end, PacketBuffer::pcClosed is posted to the message que. If the connection is not closed gracefully, and exeption is generated.
|
|
Returns if this client is connected or not.
|
|
Sends the packet.
|
|
Sends the packet.
|
|
Tries to reconnect to the server. Closes down any existing connection, and tries to connect to the server.
|
|
Sends the packet. Attempts to send the packet referenced by packet.
|
|
Sends the packet. Attempts to send the packet pointed to by pPkt. Asserts if pPkt is NULL.
|
|
Sets the socket to non-blocking mode.
|
|
Socket connected to the server.
|
|
Message que that contains any messages that have been parsed from read socket data.
|
|
Host name of the server you wish to connect to.
|
|
Port number of the server you wish to connect to.
|