Public Member Functions | Private Member Functions | List of all members
industrial::smpl_msg_connection::SmplMsgConnection Class Referenceabstract

Defines an interface and common methods for sending simple messages (see simple_message). This interface makes a bare minimum of assumptions: More...

#include <smpl_msg_connection.h>

Inheritance diagram for industrial::smpl_msg_connection::SmplMsgConnection:
Inheritance graph
[legend]

Public Member Functions

virtual bool isConnected ()=0
 return connection status More...
 
virtual bool makeConnect ()=0
 connects to the remote host More...
 
virtual bool receiveMsg (industrial::simple_message::SimpleMessage &message)
 Receives a message using the data connection. More...
 
virtual bool receiveMsg (industrial::simple_message::SimpleMessage &message, industrial::shared_types::shared_int timeout_ms)
 Receives a message using the data connection with a timeout. More...
 
bool sendAndReceiveMsg (industrial::simple_message::SimpleMessage &send, industrial::simple_message::SimpleMessage &recv, bool verbose=false)
 Performs a complete send and receive. This is helpful when sending a message that requires and explicit reply. More...
 
bool sendAndReceiveMsg (industrial::simple_message::SimpleMessage &send, industrial::simple_message::SimpleMessage &recv, industrial::shared_types::shared_int timeout_ms, bool verbose=false)
 Performs a complete send and receive with a timeout. This is helpful when sending a message that requires and explicit reply. More...
 
virtual bool sendMsg (industrial::simple_message::SimpleMessage &message)
 Sends a message using the data connection. More...
 

Private Member Functions

virtual bool receiveBytes (industrial::byte_array::ByteArray &buffer, industrial::shared_types::shared_int num_bytes, industrial::shared_types::shared_int timeout_ms)=0
 Method used by receive message interface method. This should be overridden for the specific connection type. More...
 
virtual bool sendBytes (industrial::byte_array::ByteArray &buffer)=0
 Method used by send message interface method. This should be overridden for the specific connection type. More...
 

Detailed Description

Defines an interface and common methods for sending simple messages (see simple_message). This interface makes a bare minimum of assumptions:

  1. The connection is capable of sending raw bytes (encapsulated within a simple message)
  2. The data connection has an explicit connect that establishes the connection (and an associated disconnect method). NOTE: For data connections that are connectionless, such as UDP, the connection method can be a NULL operation.

Definition at line 61 of file smpl_msg_connection.h.

Member Function Documentation

◆ isConnected()

virtual bool industrial::smpl_msg_connection::SmplMsgConnection::isConnected ( )
pure virtual

return connection status

Returns
true if connected

Implemented in industrial::simple_socket::SimpleSocket.

◆ makeConnect()

virtual bool industrial::smpl_msg_connection::SmplMsgConnection::makeConnect ( )
pure virtual

connects to the remote host

Returns
true on success, false otherwise

Implemented in industrial::tcp_client::TcpClient, industrial::tcp_server::TcpServer, industrial::udp_client::UdpClient, and industrial::udp_server::UdpServer.

◆ receiveBytes()

virtual bool industrial::smpl_msg_connection::SmplMsgConnection::receiveBytes ( industrial::byte_array::ByteArray buffer,
industrial::shared_types::shared_int  num_bytes,
industrial::shared_types::shared_int  timeout_ms 
)
privatepure virtual

Method used by receive message interface method. This should be overridden for the specific connection type.

Parameters
datato receive.
size(in bytes) of data to receive
timeout_msTimeout to receive a message (in milliseconds). A negative timeout means that this function should wait indefinitely.
Returns
true if successful

Implemented in industrial::simple_socket::SimpleSocket, and TestServer.

◆ receiveMsg() [1/2]

bool industrial::smpl_msg_connection::SmplMsgConnection::receiveMsg ( industrial::simple_message::SimpleMessage message)
virtual

Receives a message using the data connection.

Parameters
populatedwith received message
Returns
true if successful

Definition at line 80 of file smpl_msg_connection.cpp.

◆ receiveMsg() [2/2]

bool industrial::smpl_msg_connection::SmplMsgConnection::receiveMsg ( industrial::simple_message::SimpleMessage message,
industrial::shared_types::shared_int  timeout_ms 
)
virtual

Receives a message using the data connection with a timeout.

Parameters
[out]messagePopulated with received message
[in]timeout_msThe timeout for receiving a message, in milliseconds
Returns
true if successful

Definition at line 86 of file smpl_msg_connection.cpp.

◆ sendAndReceiveMsg() [1/2]

bool industrial::smpl_msg_connection::SmplMsgConnection::sendAndReceiveMsg ( industrial::simple_message::SimpleMessage send,
industrial::simple_message::SimpleMessage recv,
bool  verbose = false 
)

Performs a complete send and receive. This is helpful when sending a message that requires and explicit reply.

Parameters
messageto send
populatedwith received message
verbositylevel of low level logging
Returns
true if successful

Definition at line 133 of file smpl_msg_connection.cpp.

◆ sendAndReceiveMsg() [2/2]

bool industrial::smpl_msg_connection::SmplMsgConnection::sendAndReceiveMsg ( industrial::simple_message::SimpleMessage send,
industrial::simple_message::SimpleMessage recv,
industrial::shared_types::shared_int  timeout_ms,
bool  verbose = false 
)

Performs a complete send and receive with a timeout. This is helpful when sending a message that requires and explicit reply.

Parameters
[in]sendThe message to send
[out]recvPopulated with received message
[in]timeout_msThe timeout for receiving a message, in milliseconds
[in]verboseTurn on low level logging
Returns
true if successful

Definition at line 138 of file smpl_msg_connection.cpp.

◆ sendBytes()

virtual bool industrial::smpl_msg_connection::SmplMsgConnection::sendBytes ( industrial::byte_array::ByteArray buffer)
privatepure virtual

Method used by send message interface method. This should be overridden for the specific connection type.

Parameters
datato send.
Returns
true if successful

Implemented in industrial::simple_socket::SimpleSocket, and TestClient.

◆ sendMsg()

bool industrial::smpl_msg_connection::SmplMsgConnection::sendMsg ( industrial::simple_message::SimpleMessage message)
virtual

Sends a message using the data connection.

Parameters
messageto send
Returns
true if successful

Definition at line 57 of file smpl_msg_connection.cpp.


The documentation for this class was generated from the following files:


simple_message
Author(s): Shaun Edwards
autogenerated on Mon Jul 19 2021 12:45:19