Defines socket functions required for a simple connection type.
More...
#include <simple_socket.h>
|
| __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, industrial::shared_types::shared_int timeout_ms) |
| 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_) |
|
Defines socket functions required for a simple connection type.
Definition at line 149 of file simple_socket.h.
◆ SimpleSocket()
industrial::simple_socket::SimpleSocket::SimpleSocket |
( |
| ) |
|
|
inline |
◆ ~SimpleSocket()
virtual industrial::simple_socket::SimpleSocket::~SimpleSocket |
( |
| ) |
|
|
inlinevirtual |
◆ __attribute__()
industrial::simple_socket::SimpleSocket::__attribute__ |
( |
(deprecated( "Please use: logSocketError(const char* msg, const int rc, const int error_no)")) |
| ) |
const |
|
protected |
Logs message to error log and reports associated socket system error.
- Deprecated:
- This could report the wrong error number. The method that takes errno as an argument should be used instead.
- Parameters
-
msg | custom message prefixed to system error |
rc | return code from socket |
◆ getSockHandle()
int industrial::simple_socket::SimpleSocket::getSockHandle |
( |
| ) |
const |
|
inlineprotected |
◆ isConnected()
bool industrial::simple_socket::SimpleSocket::isConnected |
( |
| ) |
|
|
inlinevirtual |
◆ isReadyReceive()
bool industrial::simple_socket::SimpleSocket::isReadyReceive |
( |
int |
timeout | ) |
|
|
inline |
returns true if socket data is ready to receive
- Parameters
-
timeout | (ms) negative or zero values result in blocking |
- Returns
- true if data is ready to recieve
Definition at line 188 of file simple_socket.h.
◆ logSocketError()
void industrial::simple_socket::SimpleSocket::logSocketError |
( |
const char * |
msg, |
|
|
const int |
rc, |
|
|
const int |
error_no |
|
) |
| |
|
inlineprotected |
Logs message to error log and reports associated socket system error.
- Parameters
-
Definition at line 265 of file simple_socket.h.
◆ rawPoll()
virtual bool industrial::simple_socket::SimpleSocket::rawPoll |
( |
int |
timeout, |
|
|
bool & |
ready, |
|
|
bool & |
error |
|
) |
| |
|
protectedpure virtual |
◆ rawReceiveBytes()
◆ rawSendBytes()
◆ receiveBytes()
Method used by receive message interface method. This should be overridden for the specific connection type.
- Parameters
-
data | to receive. |
size | (in bytes) of data to receive |
timeout_ms | Timeout to receive a message (in milliseconds). A negative timeout means that this function should wait indefinitely. |
- Returns
- true if successful
Implements industrial::smpl_msg_connection::SmplMsgConnection.
Reimplemented in TestServer.
Definition at line 98 of file simple_socket.cpp.
◆ sendBytes()
◆ setConnected()
virtual void industrial::simple_socket::SimpleSocket::setConnected |
( |
bool |
connected | ) |
|
|
inlineprotectedvirtual |
◆ setDisconnected()
virtual void industrial::simple_socket::SimpleSocket::setDisconnected |
( |
| ) |
|
|
inlinevirtual |
◆ setSockHandle()
void industrial::simple_socket::SimpleSocket::setSockHandle |
( |
int |
sock_handle_ | ) |
|
|
inlineprotected |
◆ buffer_
◆ connected_
bool industrial::simple_socket::SimpleSocket::connected_ |
|
protected |
◆ MAX_BUFFER_SIZE
const int industrial::simple_socket::SimpleSocket::MAX_BUFFER_SIZE = 1024 |
|
staticprotected |
maximum size of buffer for receiving data (fixed memory size used in order to avoid dynamic memory allocation)
Definition at line 221 of file simple_socket.h.
◆ rc
int industrial::simple_socket::SimpleSocket::rc |
|
protected |
◆ sock_handle_
int industrial::simple_socket::SimpleSocket::sock_handle_ |
|
protected |
◆ sockaddr_
sockaddr_in industrial::simple_socket::SimpleSocket::sockaddr_ |
|
protected |
◆ SOCKET_FAIL
const int industrial::simple_socket::SimpleSocket::SOCKET_FAIL = -1 |
|
staticprotected |
◆ SOCKET_POLL_TO
const int industrial::simple_socket::SimpleSocket::SOCKET_POLL_TO = 10 |
|
staticprotected |
The documentation for this class was generated from the following files: