Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

TCPSocket Class Reference

#include <tcp.h>

Inheritance diagram for TCPSocket:

Inheritance graph
[legend]
Collaboration diagram for TCPSocket:

Collaboration graph
[legend]
List of all members.

Detailed Description

TCP/IP implementation of socket interface.

Author:
Mattias Jansson (mattias@realityrift.com)


Public Types

enum  SOCKETEVENT {
  NONE = 0x0000000, CONNECTION = 0x0000001, DATAIN = 0x0000002, ERR = 0x0000004,
  HUP = 0x0000008, NVAL = 0x0000010, TIMEOUT = 0x0000020, CONNECTED = 0x0000040
}
 Socket event identifiers (bitfield). More...


Public Member Functions

 TCPSocket (SocketCallback *pkCallback=0)
 TCPSocket (int iSocket, SocketCallback *pkCallback=0)
virtual ~TCPSocket ()
virtual bool Listen (int iPort, SocketCallback *pkCallback)
virtual bool Connect (const std::string &rstrAddr, int iPort)
int Read (void *pDst, int iBytes)
int Write (const void *pSrc, int iBytes)
virtual int GetFD ()
virtual void SetBlocking (bool bBlock=false)
virtual unsigned int Poll (int iTimeout)

Public Attributes

int m_iSocket
Threadm_pkAcceptThread
SocketCallbackm_pkCallback


Member Enumeration Documentation

enum SOCKETEVENT [inherited]
 

Socket event identifiers (bitfield).

Enumeration values:
NONE  No event
CONNECTION  Connection received
DATAIN  Data to be read
ERR  Error
HUP  Hung up
NVAL  Invalid socket
TIMEOUT  Timeout
CONNECTED  Connected


Constructor & Destructor Documentation

TCPSocket SocketCallback pkCallback = 0  ) 
 

Parameters:
pkCallback Socket callback object receiving events

TCPSocket int  iSocket,
SocketCallback pkCallback = 0
 

Parameters:
iSocket Socket descriptor
pkCallback Socket callback object receiving events

virtual ~TCPSocket  )  [virtual]
 


Member Function Documentation

virtual bool Listen int  iPort,
SocketCallback pkCallback
[virtual]
 

Listen for incoming connections

Parameters:
iPort Port to listen to
pkCallback Callback recieving connection events (will replace current callback object if not null)
Returns:
true if socket successfuly setup and accepting connections, false otherwise

virtual bool Connect const std::string &  rstrAddr,
int  iPort
[virtual]
 

Connect to other socket

Parameters:
rstrAddr Address
iPort Port
Returns:
true if connection successful, false otherwise

int Read void *  pDst,
int  iBytes
 

Read data from socket

Parameters:
pDst Destination buffer
iBytes Bytes to read
Returns:
Actual number of bytes read

int Write const void *  pSrc,
int  iBytes
 

Write data to socket

Parameters:
pSrc Source buffer
iBytes Bytes to write
Returns:
Actual number of bytes written

virtual int GetFD  )  [inline, virtual]
 

Returns:
Socket FD

Implements Socket.

virtual void SetBlocking bool  bBlock = false  )  [virtual]
 

Set blocking/nonblocking mode

Parameters:
bBlock Blocking flag

Implements Socket.

virtual unsigned int Poll int  iTimeout  )  [virtual]
 

Poll socket

Parameters:
iTimeout Timeout in milliseconds
Returns:
Events bitfield

Implements Socket.


Member Data Documentation

int m_iSocket
 

Socket descriptor

Thread* m_pkAcceptThread
 

Accept thread

SocketCallback* m_pkCallback [inherited]
 

Callback object receiving events


The documentation for this class was generated from the following file:
Generated on Wed Jan 21 14:21:15 2004 for NeoEngine by doxygen 1.3.5