Serial-TCP/IPbridge
1.0
|
TCP/IP connection. More...
#include <tcpip_connection.h>
Public Member Functions | |
virtual | ~TCPIPConnection () |
Destructor. More... | |
std::string | getAddress () const |
Returns IPv4 address of the connected node. More... | |
unsigned | getPort () const |
Returns port number through which the connected node is connected. More... | |
virtual void | close () |
Closes an established TCP connection. More... | |
Public Member Functions inherited from Connection | |
Connection (const Config &config, time_t timeout) | |
Constructor. More... | |
virtual | ~Connection () |
Destructor. More... | |
std::string | tryReceiveMessage () |
Tries to receive a message from a client. More... | |
size_t | trySendMessage (const std::string &message) |
Tries to send a message to the client. More... | |
Private Member Functions | |
TCPIPConnection (int socket, sockaddr_in socketInfo, const TCPIPConfig &config) | |
Constructor. More... | |
virtual std::string | doReceiveMessage (Config::LengthFieldMessageLength messageLength) |
Receives a message. More... | |
virtual size_t | doSendMessage (const std::string &message) |
Sends the selected message. More... | |
TCPIPConnection (const TCPIPConnection &) | |
TCPIPConnection & | operator= (const TCPIPConnection &) |
Private Attributes | |
int | _socket |
Connection socket. More... | |
sockaddr_in | _socketInfo |
Socket information. More... | |
Static Private Attributes | |
static const size_t | DEFAULT_LENGTH_FIELD_BUFFER_SIZE = 4096 |
Default buffer size used when receiving a message via length_field. More... | |
Friends | |
class | TCPIPServer |
TCP/IP connection.
Objects of this class can be created only by a TCPIPServer.
It provides reference semantics (objects copying and comparison is NOT allowed).
|
virtual |
Destructor.
|
private |
Constructor.
socket | Created and connected socket. |
socketInfo | Initialized sockaddr_in structure. |
config | Connection configuration. |
|
private |
|
virtual |
Closes an established TCP connection.
If the connection is not established, nothing will happen.
Implements Connection.
|
privatevirtual |
Receives a message.
messageLength | Length of the message. |
This operation should be nonblocking.
If there is some error, ConnectionError will be thrown. If the connection is closed, ConnectionClosed will be thrown.
Implements Connection.
|
privatevirtual |
Sends the selected message.
message | Message to be sent. |
This operation should be nonblocking.
If there is some error, ConnectionError will be thrown. If the connection is closed, ConnectionClosed will be thrown.
Implements Connection.
std::string TCPIPConnection::getAddress | ( | ) | const |
Returns IPv4 address of the connected node.
unsigned TCPIPConnection::getPort | ( | ) | const |
Returns port number through which the connected node is connected.
|
private |
|
friend |
|
private |
Connection socket.
|
private |
Socket information.
|
staticprivate |
Default buffer size used when receiving a message via length_field.