#include <SocketTransport.h> [code]
Inherits Protocols::Generics::Transport, and Protocols::Generics::SocketStatus.
Inherited by Protocols::Generics::TcpTransport.
Inheritance diagram for Protocols::Generics::SocketTransport:


Object of this class could be combined with different implementations of Socket and SocketBuffer to consistently provide the Transport interface.
SocketTransport ignores certain sequences of Socket status notifications in order to guarantee that the connected() notification is sent only once, for example. SocketTransport also delegates reading/writing from/to the Socket object to the SocketBuffer object. This allows the user to create a SocketTransport object implementing different buffering policies by providing a different SocketBuffer implementation to the SocketTransport ctor.
Definition at line 48 of file SocketTransport.h.
Public Member Functions | |
| SocketTransport () | |
| SocketTransport (Socket *socketToUse, SocketBuffer *socketBufferToUse, TransportStatus *status) | |
| Constructs a SocketTransport object. | |
| ~SocketTransport () | |
| Destructor. | |
| void | connectToNode (const Uri &) |
| Tries to establish a connection to nodeAddress. | |
| void | disconnectFromNode () |
| Disconnects from the remote node. | |
| void | abort () |
| Drops buffered data and closes the connection. | |
| bool | canRead (int count) const |
| QByteArray | peek (int count) const |
| QByteArray | peekAtMost (int count) const |
| QByteArray | peekTo (const QByteArray &delimiter) const |
| QByteArray | peekAll () const |
| QByteArray | read (int count) |
| QByteArray | readAtMost (int count) |
| QByteArray | readTo (const QByteArray &delimiter) |
| QByteArray | readAll () |
| bool | canWrite (int count) const |
| bool | write (const QByteArray &bytes, bool flush) |
| void | setTransportStatus (TransportStatus *) |
| void | socketConnected () |
| Handler for the SocketStatus::socketConnected() message. | |
| void | socketDisconnected () |
| Handler for the SocketStatus::socketDisconnected() message. | |
| void | socketError () |
| Handler for the SocketStatus::socketError() message. | |
| void | socketRead () |
| Handler for the SocketStatus::socketRead() message. | |
| void | socketWritten () |
| Handler for the SocketStatus::socketWritten() message. | |
Private Types | |
| enum | State { DisconnectedState, ConnectingState, ConnectedState, DisconnectingState } |
Private Member Functions | |
| CALITKO_TESTABLE | SocketTransport (const SocketTransport &) |
| SocketTransport & | operator= (const SocketTransport &) |
| void | tryWriteBufferToSocket (bool canSendReadyWrite) |
| void | tryReadBufferFromSocket (bool canSendReadyRead) |
Private Attributes | |
| Socket * | socket |
| SocketBuffer * | socketBuffer |
| TransportStatus * | status |
| State | state |
| bool | hasCalledWriteBufferToSocket |
| bool | hasCalledReadBufferFromSocket |
|
|
Definition at line 99 of file SocketTransport.h. |
|
|
|
|
|
|
|
||||||||||||||||
|
Constructs a SocketTransport object. socketToUse the socket object we should bind to. socketBufferToUse the socket object we would use to buffer incoming and outgoing data from and to socketToUse. statusReceiver is the object which receives our status notifications. Definition at line 34 of file SocketTransport.cpp. |
|
|
Destructor. Destroys SocketTransport object. Definition at line 50 of file SocketTransport.cpp. |
|
|
Drops buffered data and closes the connection. The disconnected() status is sent immediately. Implements Protocols::Generics::Connection. Definition at line 99 of file SocketTransport.cpp. |
|
|
Implements Protocols::Generics::Buffer. Definition at line 180 of file SocketTransport.cpp. |
|
|
Implements Protocols::Generics::Buffer. Definition at line 242 of file SocketTransport.cpp. |
|
|
Tries to establish a connection to nodeAddress. A connection attempt is started in background. Success is indicated by sending the connected() status. The disconnected() status is sent to to indicate failure.
Implements Protocols::Generics::Connection. Definition at line 67 of file SocketTransport.cpp. |
|
|
Disconnects from the remote node. The disconnection is initiated and the status disconnected() will be sent later when it is completed.
Implements Protocols::Generics::Connection. Definition at line 87 of file SocketTransport.cpp. |
|
|
|
|
|
Implements Protocols::Generics::Buffer. Definition at line 186 of file SocketTransport.cpp. |
|
|
Implements Protocols::Generics::Buffer. Definition at line 204 of file SocketTransport.cpp. |
|
|
Implements Protocols::Generics::Buffer. Definition at line 192 of file SocketTransport.cpp. |
|
|
Implements Protocols::Generics::Buffer. Definition at line 198 of file SocketTransport.cpp. |
|
|
Implements Protocols::Generics::Buffer. Definition at line 210 of file SocketTransport.cpp. |
|
|
Implements Protocols::Generics::Buffer. Definition at line 234 of file SocketTransport.cpp. |
|
|
Implements Protocols::Generics::Buffer. Definition at line 218 of file SocketTransport.cpp. |
|
|
Implements Protocols::Generics::Buffer. Definition at line 226 of file SocketTransport.cpp. |
|
|
Implements Protocols::Generics::Transport. Definition at line 298 of file SocketTransport.cpp. |
|
|
Handler for the SocketStatus::socketConnected() message. Makes sure that the connected() status message is sent only once. Implements Protocols::Generics::SocketStatus. Definition at line 111 of file SocketTransport.cpp. |
|
|
Handler for the SocketStatus::socketDisconnected() message. Makes sure that the disconnected() status message is only sent once. Implements Protocols::Generics::SocketStatus. Definition at line 124 of file SocketTransport.cpp. |
|
|
Handler for the SocketStatus::socketError() message. An established connection is directly abort()-ed in case of an error. Implements Protocols::Generics::SocketStatus. Definition at line 137 of file SocketTransport.cpp. |
|
|
Handler for the SocketStatus::socketRead() message. Try to read something from the socket and send the readyRead() status notification.
Implements Protocols::Generics::SocketStatus. Definition at line 159 of file SocketTransport.cpp. |
|
|
Handler for the SocketStatus::socketWritten() message. Try to write something to the socket and send the readyWrite() socket notification.
Implements Protocols::Generics::SocketStatus. Definition at line 174 of file SocketTransport.cpp. |
|
|
Definition at line 284 of file SocketTransport.cpp. |
|
|
Definition at line 270 of file SocketTransport.cpp. |
|
||||||||||||
|
Implements Protocols::Generics::Buffer. Definition at line 248 of file SocketTransport.cpp. |
|
|
Definition at line 112 of file SocketTransport.h. |
|
|
Definition at line 111 of file SocketTransport.h. |
|
|
Reimplemented in Protocols::Generics::TcpTransport. Definition at line 107 of file SocketTransport.h. |
|
|
Reimplemented in Protocols::Generics::TcpTransport. Definition at line 108 of file SocketTransport.h. |
|
|
Definition at line 110 of file SocketTransport.h. |
|
|
Definition at line 109 of file SocketTransport.h. |