Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
industrial::simple_socket::SimpleSocket Class Reference

Defines socket functions required for a simple connection type. More...

#include <simple_socket.h>

Inheritance diagram for industrial::simple_socket::SimpleSocket:
Inheritance graph
[legend]

List of all members.

Public Member Functions

bool isConnected ()
 return connection status
bool isReadyReceive (int timeout)
 returns true if socket data is ready to receive
virtual void setDisconnected ()
 SimpleSocket ()
 Constructor.
virtual ~SimpleSocket ()
 Destructor.

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.
int getSockHandle () const
virtual bool rawPoll (int timeout, bool &ready, bool &error)=0
 polls socket for data or error
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.
virtual void setConnected (bool connected)
void setSockHandle (int sock_handle_)

Protected Attributes

char buffer_ [MAX_BUFFER_SIZE+1]
 internal data buffer for receiving
bool connected_
 flag indicating socket connection status
int sock_handle_
 socket handle for sending/receiving data
sockaddr_in sockaddr_
 address/port of remote socket

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)
static const int SOCKET_FAIL = -1
 socket fail return value
static const int SOCKET_POLL_TO = 1000
 socket ready polling timeout (ms)

Detailed Description

Defines socket functions required for a simple connection type.

Definition at line 140 of file simple_socket.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 147 of file simple_socket.h.

Destructor.

Definition at line 157 of file simple_socket.h.


Member Function Documentation

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:
msgcustom message prefixed to system error
rcreturn code from socket
int industrial::simple_socket::SimpleSocket::getSockHandle ( ) const [inline, protected]

Definition at line 224 of file simple_socket.h.

return connection status

Returns:
true if connected

Implements industrial::smpl_msg_connection::SmplMsgConnection.

Definition at line 159 of file simple_socket.h.

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 179 of file simple_socket.h.

virtual bool industrial::simple_socket::SimpleSocket::rawPoll ( int  timeout,
bool &  ready,
bool &  error 
) [protected, pure virtual]

polls socket for data or error

Parameters:
timeout(ms) negative or zero values result in blocking
readytrue if ready
excepttrue if exception
Returns:
true if function DID NOT timeout (must check flags)

Implemented in industrial::udp_socket::UdpSocket, and industrial::tcp_socket::TcpSocket.

virtual int industrial::simple_socket::SimpleSocket::rawReceiveBytes ( char *  buffer,
industrial::shared_types::shared_int  num_bytes 
) [protected, pure virtual]
virtual int industrial::simple_socket::SimpleSocket::rawSendBytes ( char *  buffer,
industrial::shared_types::shared_int  num_bytes 
) [protected, pure 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
Returns:
true if successful

Implements industrial::smpl_msg_connection::SmplMsgConnection.

Reimplemented in TestServer.

Definition at line 98 of file simple_socket.cpp.

virtual void industrial::simple_socket::SimpleSocket::setConnected ( bool  connected) [inline, protected, virtual]

Definition at line 279 of file simple_socket.h.

Definition at line 167 of file simple_socket.h.

void industrial::simple_socket::SimpleSocket::setSockHandle ( int  sock_handle_) [inline, protected]

Definition at line 229 of file simple_socket.h.


Member Data Documentation

internal data buffer for receiving

Definition at line 222 of file simple_socket.h.

flag indicating socket connection status

Definition at line 201 of file simple_socket.h.

const int industrial::simple_socket::SimpleSocket::MAX_BUFFER_SIZE = 1024 [static, protected]

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.

socket handle for sending/receiving data

Definition at line 191 of file simple_socket.h.

address/port of remote socket

Definition at line 196 of file simple_socket.h.

const int industrial::simple_socket::SimpleSocket::SOCKET_FAIL = -1 [static, protected]

socket fail return value

Definition at line 206 of file simple_socket.h.

const int industrial::simple_socket::SimpleSocket::SOCKET_POLL_TO = 1000 [static, protected]

socket ready polling timeout (ms)

Definition at line 217 of file simple_socket.h.


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


simple_message
Author(s): Shaun Edwards
autogenerated on Tue Jan 17 2017 21:10:02