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

TCPEndpoint Class Reference

handels a TCP-Connection More...

#include <TCPEndpoint.h>

Inheritance diagram for TCPEndpoint:

Inheritance graph
[legend]
Collaboration diagram for TCPEndpoint:

Collaboration graph
[legend]
List of all members.

Public Types

enum  statusID {
  closed, connecting, connected,
  listening, sending, receiving,
  closing
}

Public Member Functions

 TCPEndpoint (int sendBufferSize=8192, int receiveBufferSize=8192)
 constructor with standard buffer size of 8192 bytes

 TCPEndpoint (char *address, int port)
 constructor which opens a connection to address:port *

 ~TCPEndpoint ()
int listen (int port)
 listens for incomming connection

int connect (char *address, int port)
 connects to another host

int send (void *Data, int size)
 sends data (data should not be changed until onSendingDone is called) if the data is bigger than sendBufferSize its splittet up and after all data is send onSendingDone is called

int close ()
 close the connection

virtual void onConnect (void)
 called by the framwork if the connection is established

virtual void onReceive (void *Data, int size)
 called when data is received

virtual void onClose (int reason)
 called when the connection ist closed by the other host

virtual void onSendingDone (void)
 called after all data from send() ist successfully send

const char * getErrorString (TCPEndpointError error)
 gets a cleartext error string

virtual void listenCont (antEnvMsg *msg)
 called by the processFramework if someone connects to a listen port

virtual void sendCont (antEnvMsg *msg)
 called by the processFramework if data was send.

virtual void receiveCont (antEnvMsg *msg)
 called by the processFramework if new data arrives

virtual void closeCont (antEnvMsg *msg)
 called by the processFreamwork after a close

virtual void connectCont (antEnvMsg *msg)
 called by the processFramework after connecting

statusID getStatus (void)

Protected Member Functions

void startReceiving ()
 internal method which calls the ANT-Library to start receiving


Protected Attributes

IPAddress address
 IP-address to connect to.

Port port
 Port to connect to.

statusID status
 status of the connection

bool wasListening
 if true the socket goes back to listening state after disconnection

int sizeOfDataToSend
 size of internal send-buffer

void * sendDataBuffer
 internal send-buffer


Private Member Functions

void sendSendMessage (int size)

Detailed Description

handels a TCP-Connection

Definition at line 17 of file TCPEndpoint.h.


Member Enumeration Documentation

enum TCPEndpoint::statusID
 

Enumeration values:
closed 
connecting 
connected 
listening 
sending 
receiving 
closing 

Definition at line 20 of file TCPEndpoint.h.

Referenced by getStatus().


Constructor & Destructor Documentation

TCPEndpoint::TCPEndpoint int  sendBufferSize = 8192,
int  receiveBufferSize = 8192
 

constructor with standard buffer size of 8192 bytes

Definition at line 18 of file TCPEndpoint.cpp.

References address, closed, status, and wasListening.

TCPEndpoint::TCPEndpoint char *  address,
int  port
 

constructor which opens a connection to address:port *

Definition at line 27 of file TCPEndpoint.cpp.

References connect().

Here is the call graph for this function:

TCPEndpoint::~TCPEndpoint  ) 
 

Definition at line 33 of file TCPEndpoint.cpp.

References close().

Here is the call graph for this function:


Member Function Documentation

int TCPEndpoint::listen int  port  ) 
 

listens for incomming connection

onConnect is called if the connection is established

Definition at line 99 of file TCPEndpoint.cpp.

References listening, status, and VERIFY.

Referenced by closeCont().

int TCPEndpoint::connect char *  address,
int  port
 

connects to another host

Definition at line 44 of file TCPEndpoint.cpp.

References connecting, and status.

Referenced by TCPEndpoint().

int TCPEndpoint::send void *  Data,
int  size
 

sends data (data should not be changed until onSendingDone is called) if the data is bigger than sendBufferSize its splittet up and after all data is send onSendingDone is called

Definition at line 151 of file TCPEndpoint.cpp.

References connected, sendDataBuffer, sendSendMessage(), sizeOfDataToSend, and status.

Referenced by TestServer::onConnect(), TestServer::onReceive(), and TCPHandler::sendPackage().

Here is the call graph for this function:

int TCPEndpoint::close  ) 
 

close the connection

Definition at line 281 of file TCPEndpoint.cpp.

References closed, closing, and status.

Referenced by TestServer::onReceive(), receiveCont(), sendCont(), and ~TCPEndpoint().

void TCPEndpoint::onConnect void   )  [virtual]
 

called by the framwork if the connection is established

Reimplemented in TestServer, and TCPHandler.

Definition at line 94 of file TCPEndpoint.cpp.

Referenced by connectCont(), and listenCont().

void TCPEndpoint::onReceive void *  Data,
int  size
[virtual]
 

called when data is received

Reimplemented in TestServer, and TCPHandler.

Definition at line 272 of file TCPEndpoint.cpp.

Referenced by receiveCont().

void TCPEndpoint::onClose int  reason  )  [virtual]
 

called when the connection ist closed by the other host

Reimplemented in TCPHandler.

Definition at line 295 of file TCPEndpoint.cpp.

Referenced by receiveCont().

void TCPEndpoint::onSendingDone void   )  [virtual]
 

called after all data from send() ist successfully send

Reimplemented in TCPHandler.

Definition at line 228 of file TCPEndpoint.cpp.

Referenced by sendCont().

const char * TCPEndpoint::getErrorString TCPEndpointError  error  ) 
 

gets a cleartext error string

Definition at line 318 of file TCPEndpoint.cpp.

Referenced by closeCont(), connectCont(), listenCont(), receiveCont(), and sendCont().

void TCPEndpoint::listenCont antEnvMsg *  msg  )  [virtual]
 

called by the processFramework if someone connects to a listen port

Reimplemented from IPEndpoint.

Definition at line 129 of file TCPEndpoint.cpp.

References connected, getErrorString(), onConnect(), startReceiving(), status, and wasListening.

Here is the call graph for this function:

void TCPEndpoint::sendCont antEnvMsg *  msg  )  [virtual]
 

called by the processFramework if data was send.

Reimplemented from IPEndpoint.

Definition at line 185 of file TCPEndpoint.cpp.

References close(), connected, getErrorString(), onSendingDone(), sendDataBuffer, sendSendMessage(), sizeOfDataToSend, and status.

Here is the call graph for this function:

void TCPEndpoint::receiveCont antEnvMsg *  msg  )  [virtual]
 

called by the processFramework if new data arrives

Reimplemented from IPEndpoint.

Definition at line 244 of file TCPEndpoint.cpp.

References close(), connected, getErrorString(), onClose(), onReceive(), startReceiving(), and status.

Here is the call graph for this function:

void TCPEndpoint::closeCont antEnvMsg *  msg  )  [virtual]
 

called by the processFreamwork after a close

Reimplemented from IPEndpoint.

Definition at line 300 of file TCPEndpoint.cpp.

References closed, getErrorString(), listen(), status, and wasListening.

Here is the call graph for this function:

void TCPEndpoint::connectCont antEnvMsg *  msg  )  [virtual]
 

called by the processFramework after connecting

Reimplemented from IPEndpoint.

Definition at line 70 of file TCPEndpoint.cpp.

References closed, connected, getErrorString(), onConnect(), startReceiving(), and status.

Here is the call graph for this function:

statusID TCPEndpoint::getStatus void   )  [inline]
 

Definition at line 55 of file TCPEndpoint.h.

References status, and statusID.

void TCPEndpoint::startReceiving  )  [protected]
 

internal method which calls the ANT-Library to start receiving

Definition at line 234 of file TCPEndpoint.cpp.

References connected, and status.

Referenced by connectCont(), listenCont(), and receiveCont().

void TCPEndpoint::sendSendMessage int  size  )  [private]
 

Definition at line 220 of file TCPEndpoint.cpp.

References status.

Referenced by send(), and sendCont().


Member Data Documentation

IPAddress TCPEndpoint::address [protected]
 

IP-address to connect to.

Definition at line 60 of file TCPEndpoint.h.

Referenced by TCPEndpoint().

Port TCPEndpoint::port [protected]
 

Port to connect to.

Definition at line 61 of file TCPEndpoint.h.

statusID TCPEndpoint::status [protected]
 

status of the connection

Definition at line 62 of file TCPEndpoint.h.

Referenced by close(), closeCont(), connect(), connectCont(), getStatus(), listen(), listenCont(), receiveCont(), send(), sendCont(), sendSendMessage(), startReceiving(), and TCPEndpoint().

bool TCPEndpoint::wasListening [protected]
 

if true the socket goes back to listening state after disconnection

Definition at line 64 of file TCPEndpoint.h.

Referenced by closeCont(), listenCont(), and TCPEndpoint().

int TCPEndpoint::sizeOfDataToSend [protected]
 

size of internal send-buffer

Definition at line 65 of file TCPEndpoint.h.

Referenced by send(), and sendCont().

void* TCPEndpoint::sendDataBuffer [protected]
 

internal send-buffer

Definition at line 66 of file TCPEndpoint.h.

Referenced by send(), and sendCont().


The documentation for this class was generated from the following files:
Generated on Thu Sep 23 20:11:58 2004 for GT2004 by doxygen 1.3.6