#include <connection.h>


Definition at line 42 of file connection.h.
Messaging API | |
| enum | SelectResult { SELECT_TIMEOUT = 0, SELECT_ERROR = -1 } |
| typedef int | ReadNotifier |
| State | _state |
| The connection state. | |
| ConnectionDescriptionPtr | _description |
| base::SpinLock | _sendLock |
| std::vector< ConnectionListener * > | _listeners |
| The listeners on state changes. | |
| class | PairConnection |
| static bool | send (const ConnectionVector &connections, const Packet &packet, const bool isLocked=false) |
| Sends a packaged message to multiple connections. | |
| static bool | send (const ConnectionVector &connections, Packet &packet, const void *data, const uint64_t size, const bool isLocked=false) |
| Sends a packaged message including additional data to multiple connections. | |
| bool | recv (void *buffer, const uint64_t bytes) |
| Read data from the connection. | |
| void | lockSend () const |
| Lock the connection, no other thread can send data. | |
| void | unlockSend () const |
| Unlock the connection. | |
| bool | send (const void *buffer, const uint64_t bytes, const bool isLocked=false) const |
| Sends data using the connection. | |
| bool | send (const Packet &packet) const |
| Sends a packaged message using the connection. | |
| bool | send (Packet &packet, const std::string &string) const |
| Sends a packaged message including a string using the connection. | |
| template<typename T> | |
| bool | send (Packet &packet, const std::vector< T > &data) const |
| Sends a packaged message including additional data. | |
| bool | send (Packet &packet, const void *data, const uint64_t size) const |
| Sends a packaged message including additional data using the connection. | |
| virtual ReadNotifier | getReadNotifier () const |
| Connection () | |
| Connection (const Connection &conn) | |
| virtual | ~Connection () |
| void | _fireStateChanged () |
Public Types | |
| enum | State { STATE_CLOSED, STATE_CONNECTING, STATE_CONNECTED, STATE_LISTENING } |
Public Member Functions | |
| template<typename T> | |
| bool | send (Packet &packet, const std::vector< T > &data) const |
Data Access. | |
| State | getState () const |
| Returns the state of this connection. | |
| bool | isClosed () const |
| bool | isConnected () const |
| bool | isListening () const |
| void | setDescription (ConnectionDescriptionPtr description) |
| Set the connection's description. | |
| ConnectionDescriptionPtr | getDescription () const |
Connection Management | |
| virtual bool | connect () |
| Connect to the remote peer. | |
| virtual bool | listen () |
| Put the connection into the listening state for a new incoming connection. | |
| virtual ConnectionPtr | accept () |
| Accepts the next incoming connection. | |
| virtual ConnectionPtr | accept (const int timeout) |
| Accepts the next incoming connection with a timeout. | |
| virtual void | close () |
| Closes a connected or listening connection. | |
Listener Interface | |
| void | addListener (ConnectionListener *listener) |
| Add a listener for connection state changes. | |
| void | removeListener (ConnectionListener *listener) |
| Remove a listener for connection state changes. | |
Static Public Member Functions | |
| static ConnectionPtr | create (ConnectionDescriptionPtr description) |
| Creates a new connection. | |
Protected Member Functions | |
Input/Output | |
| virtual int64_t | read (void *buffer, const uint64_t bytes)=0 |
| Read data from the connection. | |
| virtual int64_t | write (const void *buffer, const uint64_t bytes) const =0 |
| Write data to the connection. | |
| typedef int eq::net::Connection::ReadNotifier |
Definition at line 253 of file connection.h.
| ConnectionPtr eq::net::Connection::create | ( | ConnectionDescriptionPtr | description | ) | [static] |
Creates a new connection.
This factory method creates a new concrete connection for the requested type. The concrete connection may not support all functionality of the Connection interface.
| description | describing the connection to be created. |
Definition at line 52 of file connection.cpp.
References eq::net::CONNECTIONTYPE_PIPE, eq::net::CONNECTIONTYPE_SDP, and eq::net::CONNECTIONTYPE_TCPIP.
Referenced by eq::net::Node::initConnect(), and eq::net::Node::listen().

| State eq::net::Connection::getState | ( | ) | const [inline] |
Returns the state of this connection.
Definition at line 72 of file connection.h.
| bool eq::net::Connection::isClosed | ( | ) | const [inline] |
| bool eq::net::Connection::isConnected | ( | ) | const [inline] |
Definition at line 78 of file connection.h.
| bool eq::net::Connection::isListening | ( | ) | const [inline] |
Definition at line 81 of file connection.h.
| void eq::net::Connection::setDescription | ( | ConnectionDescriptionPtr | description | ) |
Set the connection's description.
| description | the connection parameters. |
Definition at line 394 of file connection.cpp.
References eq::base::RefPtr< T >::isValid().

| ConnectionDescriptionPtr eq::net::Connection::getDescription | ( | ) | const |
| virtual bool eq::net::Connection::connect | ( | ) | [inline, virtual] |
Connect to the remote peer.
true if the connection was successfully connected, false if not. Reimplemented in eq::net::PairConnection, eq::net::PipeConnection, and eq::net::SocketConnection.
Definition at line 102 of file connection.h.
| virtual bool eq::net::Connection::listen | ( | ) | [inline, virtual] |
Put the connection into the listening state for a new incoming connection.
true if the connection is listening for new incoming connections, false if not. Reimplemented in eq::net::SocketConnection.
Definition at line 111 of file connection.h.
| virtual ConnectionPtr eq::net::Connection::accept | ( | ) | [inline, virtual] |
Accepts the next incoming connection.
Reimplemented in eq::net::SocketConnection.
Definition at line 119 of file connection.h.
Referenced by accept().

| ConnectionPtr eq::net::Connection::accept | ( | const int | timeout | ) | [virtual] |
Accepts the next incoming connection with a timeout.
| timeout | the amount of time to wait in milliseconds, if set to -1 the method blocks indefinitely. |
Definition at line 75 of file connection.cpp.
References _state, and accept().

| void eq::net::Connection::addListener | ( | ConnectionListener * | listener | ) |
Add a listener for connection state changes.
Definition at line 121 of file connection.cpp.
References _listeners.
| void eq::net::Connection::removeListener | ( | ConnectionListener * | listener | ) |
Remove a listener for connection state changes.
Definition at line 126 of file connection.cpp.
References _listeners.
| bool eq::net::Connection::recv | ( | void * | buffer, | |
| const uint64_t | bytes | |||
| ) |
Read data from the connection.
| buffer | the buffer for saving the message. | |
| bytes | the number of bytes to read. |
Definition at line 147 of file connection.cpp.
References _state, eq::base::disableFlush(), eq::base::enableFlush(), and read().

| void eq::net::Connection::lockSend | ( | ) | const [inline] |
Lock the connection, no other thread can send data.
Definition at line 159 of file connection.h.
Referenced by send().

| void eq::net::Connection::unlockSend | ( | ) | const [inline] |
Unlock the connection.
Definition at line 161 of file connection.h.
Referenced by send().

| bool eq::net::Connection::send | ( | const void * | buffer, | |
| const uint64_t | bytes, | |||
| const bool | isLocked = false | |||
| ) | const |
Sends data using the connection.
| buffer | the buffer containing the message. | |
| bytes | the number of bytes to send. | |
| isLocked | true if the connection is locked externally. |
Definition at line 218 of file connection.cpp.
References _state, eq::base::disableFlush(), eq::base::enableFlush(), and write().
Referenced by send(), eq::net::ObjectInstanceDataOStream::sendBuffer(), eq::net::ObjectDeltaDataOStream::sendBuffer(), eq::net::ObjectInstanceDataOStream::sendFooter(), and eq::net::ObjectDeltaDataOStream::sendFooter().


| bool eq::net::Connection::send | ( | const Packet & | packet | ) | const [inline] |
Sends a packaged message using the connection.
| packet | the message packet. |
Definition at line 180 of file connection.h.
References eq::net::Packet::size.
| bool eq::net::Connection::send | ( | Packet & | packet, | |
| const std::string & | string | |||
| ) | const [inline] |
Sends a packaged message including a string using the connection.
| packet | the message packet. | |
| string | the string. |
Definition at line 190 of file connection.h.
| bool eq::net::Connection::send | ( | Packet & | packet, | |
| const std::vector< T > & | data | |||
| ) | const [inline] |
Sends a packaged message including additional data.
The last item of the packet has to be able to hold one item or eight bytes of the data, whatever is bigger.
| packet | the message packet. | |
| data | the vector containing the data. |
Definition at line 315 of file connection.h.
| bool eq::net::Connection::send | ( | Packet & | packet, | |
| const void * | data, | |||
| const uint64_t | size | |||
| ) | const |
Sends a packaged message including additional data using the connection.
| packet | the message packet. | |
| data | the data. | |
| size | the data size in bytes. |
Definition at line 281 of file connection.cpp.
References lockSend(), send(), eq::net::Packet::size, and unlockSend().

| bool eq::net::Connection::send | ( | const ConnectionVector & | connections, | |
| const Packet & | packet, | |||
| const bool | isLocked = false | |||
| ) | [static] |
Sends a packaged message to multiple connections.
| connections | The connections. | |
| packet | the message packet. | |
| isLocked | true if the connection is locked externally. |
Definition at line 318 of file connection.cpp.
References eq::net::Packet::size.
| bool eq::net::Connection::send | ( | const ConnectionVector & | connections, | |
| Packet & | packet, | |||
| const void * | data, | |||
| const uint64_t | size, | |||
| const bool | isLocked = false | |||
| ) | [static] |
Sends a packaged message including additional data to multiple connections.
| connections | The connections. | |
| packet | the message packet. | |
| data | the data. | |
| size | the data size in bytes. | |
| isLocked | true if the connection is locked externally. |
Definition at line 333 of file connection.cpp.
References send(), and eq::net::Packet::size.

| virtual int64_t eq::net::Connection::read | ( | void * | buffer, | |
| const uint64_t | bytes | |||
| ) | [protected, pure virtual] |
Read data from the connection.
Note the the a return value of 0 is not an error condition, it means that no data was pending on a non-blocking connection.
| buffer | the buffer for saving the message. | |
| bytes | the number of bytes to read. |
Implemented in eq::net::BufferConnection, eq::net::FDConnection, and eq::net::PairConnection.
Referenced by recv().

| virtual int64_t eq::net::Connection::write | ( | const void * | buffer, | |
| const uint64_t | bytes | |||
| ) | const [protected, pure virtual] |
Write data to the connection.
| buffer | the buffer containing the message. | |
| bytes | the number of bytes to write. |
Implemented in eq::net::BufferConnection, eq::net::FDConnection, and eq::net::PairConnection.
Referenced by send().

0.6 by
1.5.5