MISOCKET::CLIENT Class Reference

Base class for any client that wants to be notified of a socket's state. More...

#include <mi32/socket.h>

List of all members.

Classes

class  LOCK

Public Member Functions

 CLIENT (MISOCKET *sock, bool bTakeOwnership=true)
 CLIENT ()
virtual ~CLIENT ()
bool CallOnAccept (MISOCKET *socket, const MISOCKET::ADDR &addr)
void CallOnClose ()
void CallOnConnect ()
void CallOnReadReady ()
void CallOnTimeOut ()
void CallOnWriteReady ()
ERRVALUE Connect (const MISOCKET::ADDR &address)
MISOCKETGetSocket () const
bool IsConnected () const
void SetSocket (MISOCKET *sock, bool bTakeOwnership=true)

Protected Member Functions

void Destroy ()

Private Member Functions

virtual bool v_OnAccept (MISOCKET *socket, const MISOCKET::ADDR &addr)
virtual void v_OnClose ()
virtual void v_OnConnect ()
virtual void v_OnReadReady ()
virtual void v_OnTimeOut ()
virtual void v_OnWriteReady ()

Detailed Description

Base class for any client that wants to be notified of a socket's state.


Constructor & Destructor Documentation

MISOCKET::CLIENT::CLIENT (  ) 
MISOCKET::CLIENT::CLIENT ( MISOCKET sock,
bool  bTakeOwnership = true 
)

Constructor.

Parameters:
sock The socket to watch. Can be NULL to indicate that we're not watching anything.
bTakeOwnership If true (the default) then this CLIENT "owns" the socket and will delete it.
virtual MISOCKET::CLIENT::~CLIENT (  )  [virtual]

Destructor.

If we "own" a socket, it will be deleted as well. Warning: Do NOT destroy client from within one if its virtual methods. The caller of that virtual method may not be done with the "this" yet. Call Destroy() from withing virtual methods.


Member Function Documentation

bool MISOCKET::CLIENT::CallOnAccept ( MISOCKET socket,
const MISOCKET::ADDR addr 
)
void MISOCKET::CLIENT::CallOnClose (  ) 

Will be called when the socket is closed out from under us (dropped connection or some such event).

WARNING: Do NOT destroy "this" from within this method or bad things may happen. Call Destroy() instead.

void MISOCKET::CLIENT::CallOnConnect (  ) 

Will be called when a Connect call completes if the socket was non blocking.

void MISOCKET::CLIENT::CallOnReadReady (  ) 

Will be called when there is data available if a previous read couldn't be filled and the socket was non-blocking.

void MISOCKET::CLIENT::CallOnTimeOut (  ) 

Will be called if a timeout interval has been set and a previous call has timed out.

void MISOCKET::CLIENT::CallOnWriteReady (  ) 

Will be called when the socket is ready to be written to.

ERRVALUE MISOCKET::CLIENT::Connect ( const MISOCKET::ADDR address  ) 

Connect to a remote server.

void MISOCKET::CLIENT::Destroy (  )  [protected]

Destroy the client.

For use from within virtual methods.

MISOCKET* MISOCKET::CLIENT::GetSocket (  )  const

Get the current socket for this client.

Returns:
a MISOCKET or NULL if no socket being monitored.
bool MISOCKET::CLIENT::IsConnected (  )  const

Determine if this client is connected to anything.

void MISOCKET::CLIENT::SetSocket ( MISOCKET sock,
bool  bTakeOwnership = true 
)

Set the socket to watch.

If we're already watching a socket, that socket is first informed that we're no longer watching it. If we "own" the existing socket, it is deleted. If the socket is deleted out from under us, its destructor will reset our socket back to NULL.

Parameters:
sock The socket to watch. Can be NULL to indicate that we're not watching anything.
bTakeOwnership If true (the default) then this CLIENT "owns" the socket and will delete it.
virtual bool MISOCKET::CLIENT::v_OnAccept ( MISOCKET socket,
const MISOCKET::ADDR addr 
) [private, virtual]

Will be called if a previous call to Accept() failed because the socket is non-blocking and the call would have blocked, but would now succeed.

Will be passed a pointer to the already accepted socket. If you wish to reject the connection, return false, and the caller will delete the socket for you. If you wish to accept the connection, return true. You are then responsible for deleting the socket when you're done with it.

virtual void MISOCKET::CLIENT::v_OnClose (  )  [private, virtual]

Will be called when the socket is closed out from under us (dropped connection or some such event).

WARNING: Do NOT destroy "this" from within this method or bad things may happen. Call Destroy() instead.

virtual void MISOCKET::CLIENT::v_OnConnect (  )  [private, virtual]

Will be called when a Connect call completes if the socket was non blocking.

virtual void MISOCKET::CLIENT::v_OnReadReady (  )  [private, virtual]

Will be called when there is data available if a previous read couldn't be filled and the socket was non-blocking.

virtual void MISOCKET::CLIENT::v_OnTimeOut (  )  [private, virtual]

Will be called if a timeout interval has been set and a previous call has timed out.

virtual void MISOCKET::CLIENT::v_OnWriteReady (  )  [private, virtual]

Will be called when the socket is ready to be written to.


The documentation for this class was generated from the following file:

Generated on Sun Oct 7 21:33:39 2012 for TNTsdk 2012 by  doxygen 1.6.1