#include <TcpSocket.h> [code]
Inherits QObject, and Protocols::Generics::Socket.
Inheritance diagram for Protocols::Generics::TcpSocket:


This class implements the Socket interface on top of QTcpSocket. It converts the Qt signals emitted by QTcpSockets to calls to the SocketStatus interface. It also makes sure that its notifications are sent synchronously or asynchronously in a consistent manner:
Definition at line 49 of file TcpSocket.h.
Public Member Functions | |
| TcpSocket (auto_ptr< QTcpSocket > socket, SocketStatus *status) | |
| Constructs a new TcpSocket object and attaches it to socket. | |
| ~TcpSocket () | |
| Destroys a TcpSocket object. If not disconnected abort() is called. | |
| void | connectToHost (const QHostAddress &address, quint16 port) |
| Tries to establish a connection to the remote host. | |
| void | disconnectFromHost () |
| Disconnects the socket from the remote Host. | |
| void | abort () |
| Aborts all ongoing operations and closes the socket. | |
| qint64 | read (char *destination, qint64 size) |
| Reads data from socket. | |
| qint64 | write (const char *source, qint64 size) |
| Writes data to socket. | |
Private Slots | |
| void | slotConnected () |
| Sends the socketConnected() status notification. | |
| void | slotDisconnected () |
| Sends the socketDisconnected() status notification. | |
| void | slotError () |
| Schedules a delayed socketError() status notification. | |
| void | slotRead () |
| Sends the socketRead() status notification. | |
| void | slotWritten () |
| Sends the socketWritten() status notification. | |
| void | delayedError () |
| A slot called after the slotError() gets called to report an error. | |
| void | delayedDisconnectFromHost () |
| A slot called after disconnectFromHost() was called. | |
Private Attributes | |
| auto_ptr< QTcpSocket > | socket |
| SocketStatus * | status |
|
||||||||||||
|
Constructs a new TcpSocket object and attaches it to socket. socket_ will be owned by the TcpSocket object. status_ is the required interface over which send status notifications.
Definition at line 36 of file TcpSocket.cpp. |
|
|
Destroys a TcpSocket object. If not disconnected abort() is called.
Definition at line 60 of file TcpSocket.cpp. |
|
|
Aborts all ongoing operations and closes the socket.
Implements Protocols::Generics::Socket. Definition at line 92 of file TcpSocket.cpp. |
|
||||||||||||
|
Tries to establish a connection to the remote host.
Implements Protocols::Generics::Socket. Definition at line 71 of file TcpSocket.cpp. |
|
|
A slot called after disconnectFromHost() was called. This is to ensure that the slotDisconnected() is not entered from within the TcpSocket::disconnectFromHost() call. Definition at line 178 of file TcpSocket.cpp. |
|
|
A slot called after the slotError() gets called to report an error.
Definition at line 168 of file TcpSocket.cpp. |
|
|
Disconnects the socket from the remote Host. socket->disconnectFromHost() could emit disconnected() emidiately in case the write buffer is empty! We want our status socketDisconnected() to always be sent asynchronously, so we invoke the socket method with a delay. Implements Protocols::Generics::Socket. Definition at line 84 of file TcpSocket.cpp. |
|
||||||||||||
|
Reads data from socket. destination is the starting address of the buffer where the read bytes should be copied to. size is the size of the destination buffer. At most size bytes will be copied to it.
Implements Protocols::Generics::Socket. Definition at line 108 of file TcpSocket.cpp. |
|
|
Sends the socketConnected() status notification.
Definition at line 132 of file TcpSocket.cpp. |
|
|
Sends the socketDisconnected() status notification.
Definition at line 138 of file TcpSocket.cpp. |
|
|
Schedules a delayed socketError() status notification. Because the user is likely to abort() upon an error, we don't want to abort() from within a failing read/write operation, therefore we use Qt::QueuedConnection to schedule a delayed call to delayedError(), which will send the socketError() notification. Definition at line 150 of file TcpSocket.cpp. |
|
|
Sends the socketRead() status notification.
Definition at line 156 of file TcpSocket.cpp. |
|
|
Sends the socketWritten() status notification.
Definition at line 162 of file TcpSocket.cpp. |
|
||||||||||||
|
Writes data to socket. source is the starting address of the buffer from which the bytes should be written to the socket. size is the size of the source buffer. At most size bytes will be written from it.
Implements Protocols::Generics::Socket. Definition at line 125 of file TcpSocket.cpp. |
|
|
Definition at line 76 of file TcpSocket.h. |
|
|
Definition at line 77 of file TcpSocket.h. |