Defines socket functions required for a simple connection type. More...
#include <simple_socket.h>
Public Member Functions | |
bool | isConnected () |
return connection status More... | |
bool | isReadyReceive (int timeout) |
returns true if socket data is ready to receive More... | |
virtual void | setDisconnected () |
SimpleSocket () | |
Constructor. More... | |
virtual | ~SimpleSocket () |
Destructor. More... | |
Public Member Functions inherited from industrial::smpl_msg_connection::SmplMsgConnection | |
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... | |
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... | |
virtual bool | sendMsg (industrial::simple_message::SimpleMessage &message) |
Sends a message using the data connection. More... | |
Protected Member Functions | |
__attribute__ ((deprecated("Please use: logSocketError(const char* msg, const int rc, const int error_no)"))) void logSocketError(const char *msg | |
Logs message to error log and reports associated socket system error. More... | |
int | getSockHandle () const |
void | logSocketError (const char *msg, const int rc, const int error_no) |
Logs message to error log and reports associated socket system error. More... | |
virtual bool | rawPoll (int timeout, bool &ready, bool &error)=0 |
polls socket for data or error More... | |
virtual int | rawReceiveBytes (char *buffer, industrial::shared_types::shared_int num_bytes)=0 |
virtual int | rawSendBytes (char *buffer, industrial::shared_types::shared_int num_bytes)=0 |
bool | receiveBytes (industrial::byte_array::ByteArray &buffer, industrial::shared_types::shared_int num_bytes) |
Method used by receive message interface method. This should be overridden for the specific connection type. More... | |
bool | sendBytes (industrial::byte_array::ByteArray &buffer) |
Method used by send message interface method. This should be overridden for the specific connection type. More... | |
virtual void | setConnected (bool connected) |
void | setSockHandle (int sock_handle_) |
Protected Attributes | |
char | buffer_ [MAX_BUFFER_SIZE+1] |
internal data buffer for receiving More... | |
bool | connected_ |
flag indicating socket connection status More... | |
int | rc |
int | sock_handle_ |
socket handle for sending/receiving data More... | |
sockaddr_in | sockaddr_ |
address/port of remote socket More... | |
Static Protected Attributes | |
static const int | MAX_BUFFER_SIZE = 1024 |
maximum size of buffer for receiving data (fixed memory size used in order to avoid dynamic memory allocation) More... | |
static const int | SOCKET_FAIL = -1 |
socket fail return value More... | |
static const int | SOCKET_POLL_TO = 1000 |
socket ready polling timeout (ms) More... | |
Defines socket functions required for a simple connection type.
Definition at line 140 of file simple_socket.h.
|
inline |
Constructor.
Definition at line 147 of file simple_socket.h.
|
inlinevirtual |
Destructor.
Definition at line 157 of file simple_socket.h.
|
protected |
Logs message to error log and reports associated socket system error.
msg | custom message prefixed to system error |
rc | return code from socket |
|
inlineprotected |
Definition at line 224 of file simple_socket.h.
|
inlinevirtual |
return connection status
Implements industrial::smpl_msg_connection::SmplMsgConnection.
Definition at line 159 of file simple_socket.h.
|
inline |
returns true if socket data is ready to receive
timeout | (ms) negative or zero values result in blocking |
Definition at line 179 of file simple_socket.h.
|
inlineprotected |
Logs message to error log and reports associated socket system error.
msg | custom message prefixed to system error |
rc | return code from socket |
error_no | errno value see (http://man7.org/linux/man-pages/man3/errno.3.html ) |
Definition at line 254 of file simple_socket.h.
|
protectedpure virtual |
polls socket for data or error
timeout | (ms) negative or zero values result in blocking |
ready | true if ready |
except | true if exception |
Implemented in industrial::udp_socket::UdpSocket, and industrial::tcp_socket::TcpSocket.
|
protectedpure virtual |
Implemented in industrial::udp_socket::UdpSocket, and industrial::tcp_socket::TcpSocket.
|
protectedpure virtual |
Implemented in industrial::udp_socket::UdpSocket, and industrial::tcp_socket::TcpSocket.
|
protectedvirtual |
Method used by receive message interface method. This should be overridden for the specific connection type.
data | to receive. |
size | (in bytes) of data to receive |
Implements industrial::smpl_msg_connection::SmplMsgConnection.
Reimplemented in TestServer.
Definition at line 98 of file simple_socket.cpp.
|
protectedvirtual |
Method used by send message interface method. This should be overridden for the specific connection type.
data | to send. |
Implements industrial::smpl_msg_connection::SmplMsgConnection.
Reimplemented in TestClient.
Definition at line 48 of file simple_socket.cpp.
|
inlineprotectedvirtual |
Definition at line 279 of file simple_socket.h.
|
inlinevirtual |
Definition at line 167 of file simple_socket.h.
|
inlineprotected |
Definition at line 229 of file simple_socket.h.
|
protected |
internal data buffer for receiving
Definition at line 222 of file simple_socket.h.
|
protected |
flag indicating socket connection status
Definition at line 201 of file simple_socket.h.
|
staticprotected |
maximum size of buffer for receiving data (fixed memory size used in order to avoid dynamic memory allocation)
Definition at line 212 of file simple_socket.h.
|
protected |
Definition at line 244 of file simple_socket.h.
|
protected |
socket handle for sending/receiving data
Definition at line 191 of file simple_socket.h.
|
protected |
address/port of remote socket
Definition at line 196 of file simple_socket.h.
|
staticprotected |
socket fail return value
Definition at line 206 of file simple_socket.h.
|
staticprotected |
socket ready polling timeout (ms)
Definition at line 217 of file simple_socket.h.