Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

network
Class CStreamSocket

CSocketBase
   |
   +--CStreamSocket

   in StreamSocket.h
   in StreamSocket.cpp
Direct Known Subclasses:
CMessageSocket

class CStreamSocket
extends CSocketBase

A class implementing Async I/O on top of the non-blocking event-driven CSocketBase


Inner Classes, Typedefs, and Enums
struct CStreamSocket::SOperationContext
          
 
Field Summary
private int m_ConnectPort
          
private CMutex m_Mutex
          
private char* m_pConnectHost
          
private CStreamSocket::SOperationContext m_ReadContext
          
private CStreamSocket::SOperationContext m_WriteContext
          
 
Constructor Summary
protected  CStreamSocket( CSocketInternal* pInt )
          
  CStreamSocket()
          
protected  virtual ~CStreamSocket()
          The destructor will disconnect the socket and free any OS resources.
 
Method Summary
 PS_RESULT BeginConnect( const char* hostname, int port )
          Begin a connect operation to the specified host and port.
 virtual void ConnectComplete( PS_RESULT errorCode )
          
 void Lock()
          The Lock function locks a mutex stored in the CStreamSocket object.
 virtual void OnClose( PS_RESULT errorCode )
          
protected virtual void OnRead()
          
protected virtual void OnWrite()
          
 PS_RESULT Read( void* buf, uint len )
          Start a read operation.
 virtual void ReadComplete( PS_RESULT errorCode )
          
protected void SetSocketOptions()
          Set the required socket options on the socket.
 void Unlock()
          The Unlock function unlocks a mutex stored in the CStreamSocket object.
 PS_RESULT Write( void* buf, uint len )
          Start a Write operation.
 virtual void WriteComplete( PS_RESULT errorCode )
          
   
Methods inherited from class CSocketBase
Shutdown, Initialize, Close, Destroy, SetNonBlocking, SetTcpNoDelay, Read, Write, Connect, Bind, PreAccept, Accept, Reject, GetOpMask, SetOpMask, GetProtocol, IsNonBlocking, GetErrorState, GetState, GetRemoteAddress, OnRead, OnWrite, OnClose
 

Field Detail

m_ConnectPort

private int m_ConnectPort;

m_Mutex

private CMutex m_Mutex;

m_pConnectHost

private char* m_pConnectHost;

m_ReadContext

private CStreamSocket::SOperationContext m_ReadContext;

m_WriteContext

private CStreamSocket::SOperationContext m_WriteContext;


Constructor Detail

CStreamSocket

protected CStreamSocket( CSocketInternal* pInt );

CStreamSocket

public CStreamSocket();

~CStreamSocket

protected virtual ~CStreamSocket();
The destructor will disconnect the socket and free any OS resources.


Method Detail

BeginConnect

public PS_RESULT BeginConnect( const char* hostname, int port );
Begin a connect operation to the specified host and port. The connect operation and name resolution is performed in the background and the ConnectComplete callback is called when the connect is complete/failed Note that a PS_OK return only means that the connect operation has been initiated, not that it is successful.
Parameters:
hostname - A hostname or an IP address of the remote host
port - The TCP port number in host byte order
Returns:
PS_OK - The connect has been initiated

ConnectComplete

public virtual void ConnectComplete( PS_RESULT errorCode );

Lock

public void Lock();
The Lock function locks a mutex stored in the CStreamSocket object. None of the CStreamSocket methods actually use the mutex, it is just there as a convenience for the user.

OnClose

public virtual void OnClose( PS_RESULT errorCode );

OnRead

protected virtual void OnRead();

OnWrite

protected virtual void OnWrite();

Read

public PS_RESULT Read( void* buf, uint len );
Start a read operation. The function call will return immediately and complete the I/O in the background. OnRead() will be called when it is complete. Until the Read is complete, the buffer should not be touched. There can only be one read operation in progress at one time. Inputs buf A pointer to the buffer where the data should be written len The length of the buffer. The amount of data the function should try to read. Returns PS_OK Some or all data was successfully read. CONFLICTING_OP_IN_PROGRESS Another Read operation is alread in progress CONNECTION_BROKEN The socket is not connected or a server socket

ReadComplete

public virtual void ReadComplete( PS_RESULT errorCode );

SetSocketOptions

protected void SetSocketOptions();
Set the required socket options on the socket.

Unlock

public void Unlock();
The Unlock function unlocks a mutex stored in the CStreamSocket object. None of the CSocket methods actually use the mutex, it is just there as a convenience for the user.

Write

public PS_RESULT Write( void* buf, uint len );
Start a Write operation. The function call will return immediately and the I/O complete in the background. OnWrite() will be called when i has completed. Until the Write is complete, the buffer shouldn't be touched. There can only be one write operation in progress at one time.
Parameters:
buf - A pointer to the buffer of data to write
len - The length of the buffer. Returns PS_OK Some or all data was successfully read. CONFLICTING_OP_IN_PROGRESS Another Write operation is in progress CONNECTION_BROKEN The socket is not connected or a server socket

WriteComplete

public virtual void WriteComplete( PS_RESULT errorCode );

 Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
Generated on September 04, 2007 at 18:13
CppDoc v2.4.0
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD