#include <bidirectionalconnection.h>
Inheritance diagram for Yagl::BiDirectionalConnection:

Public Member Functions | |
| BiDirectionalConnection () | |
| Constructor. | |
| virtual | ~BiDirectionalConnection () |
| Destructor. | |
| bool | isAlive () |
| returns true or false depending on wheter the connection is still alive | |
| void | setSocket (int socket) |
| sets the socket descriptor | |
| void | setLocalPort (unsigned short port) |
| sets the local port | |
| void | setRemoteAddress (std::string address) |
| sets the remote address | |
| void | setRemoteAddress (std::string &address) |
| sets the remote address | |
| void | setRemotePort (unsigned short port) |
| sets the remote port | |
| bool | connect (const char *address, unsigned short port) |
| connects to the given destination | |
| void | registerMessageReceiver (MessageReceiver *receiver) |
| registers a message receiver | |
| void | unregisterMessageReceiver (MessageReceiver *receiver) |
| unregisters a message receiver | |
| void | disconnect () |
| disconnects | |
| bool | send (Message &message) |
| sends the given message | |
| void | receive () |
| the threaded receive loop | |
| void * | run () |
| for internal usage only ( threading ) | |
Protected Member Functions | |
| BiDirectionalConnection (const BiDirectionalConnection &connection) | |
Protected Attributes | |
| int | socket_ |
| socket descriptor | |
|
|
copy constructor hidden |
|
|
Constructor. sets up internal members |
|
|
Destructor. disconnects if the conection is still open and stops the receiving thread |
|
||||||||||||
|
connects to the given destination this method will try to connect to the given address and port. if the connection attempt is successfully the receiving thread is started and true is returned. if the connection attempt was not successfull false is returned
|
|
|
disconnects this disconnects a connection. then receiving thread will be exited if running. |
|
|
the threaded receive loop this is the threaded receive loop that will wait for incoming messages and pass them to the message receiver. messages will only be passed to the receivers when they are fully reassembled ( as they can get fragmented over the network ) the thread will start receiving as soon as there is at least one message receiver registered. |
|
|
registers a message receiver this method should be called before connecting to a remote host. it will register a message receiver that will receive any incoming messages. one can register as many receivers as he/she wants. in case of an accepted incoming connection returned by ListeningConnection one can register a new receiver too. the receive thread will wait until the first receiver is registered and only then start to actually receive data. |
|
|
sends the given message this will send the given message if the connection is open. the message size is irrelevant in that case as it will be split up into 2kb packages that have a good throughput ratio. it is no problem to send multiple megabyte big message in one go.
|
|
|
sets the local port this method sets the local port this connection should work on. call this function prior to connect if you want the connection to work on a certain port. if the connection is already running (e.g. it was returned from a ListeningConnection) a call to this method has no effect |
|
|
sets the remote address for internal usage |
|
|
sets the remote address for internal usage |
|
|
sets the remote port for internal usage |
|
|
sets the socket descriptor for internal usage only |
|
|
unregisters a message receiver this will unregister a message receiver. |
1.4.5