Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
industrial::udp_socket::UdpSocket Class Reference

#include <udp_socket.h>

Inheritance diagram for industrial::udp_socket::UdpSocket:
Inheritance graph
[legend]

Public Member Functions

 UdpSocket ()
 
 ~UdpSocket ()
 
- Public Member Functions inherited from industrial::simple_socket::SimpleSocket
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...
 
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...
 

Protected Member Functions

bool rawPoll (int timeout, bool &ready, bool &error)
 polls socket for data or error More...
 
int rawReceiveBytes (char *buffer, industrial::shared_types::shared_int num_bytes)
 
int rawSendBytes (char *buffer, industrial::shared_types::shared_int num_bytes)
 
- Protected Member Functions inherited from industrial::simple_socket::SimpleSocket
 __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...
 
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_)
 

Protected Attributes

char udp_read_buffer_ [MAX_BUFFER_SIZE+1]
 
char * udp_read_head_
 
size_t udp_read_len_
 
- Protected Attributes inherited from industrial::simple_socket::SimpleSocket
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 char CONNECT_HANDSHAKE = 142
 udp socket connect handshake value More...
 
- Static Protected Attributes inherited from industrial::simple_socket::SimpleSocket
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 = 10
 socket ready polling timeout (ms) More...
 

Detailed Description

Definition at line 67 of file udp_socket.h.

Constructor & Destructor Documentation

◆ UdpSocket()

industrial::udp_socket::UdpSocket::UdpSocket ( )

Definition at line 53 of file udp_socket.cpp.

◆ ~UdpSocket()

industrial::udp_socket::UdpSocket::~UdpSocket ( )

Definition at line 61 of file udp_socket.cpp.

Member Function Documentation

◆ rawPoll()

bool industrial::udp_socket::UdpSocket::rawPoll ( int  timeout,
bool &  ready,
bool &  error 
)
protectedvirtual

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)

Implements industrial::simple_socket::SimpleSocket.

Definition at line 105 of file udp_socket.cpp.

◆ rawReceiveBytes()

int industrial::udp_socket::UdpSocket::rawReceiveBytes ( char *  buffer,
industrial::shared_types::shared_int  num_bytes 
)
protectedvirtual

Implements industrial::simple_socket::SimpleSocket.

Definition at line 79 of file udp_socket.cpp.

◆ rawSendBytes()

int industrial::udp_socket::UdpSocket::rawSendBytes ( char *  buffer,
industrial::shared_types::shared_int  num_bytes 
)
protectedvirtual

Implements industrial::simple_socket::SimpleSocket.

Definition at line 68 of file udp_socket.cpp.

Member Data Documentation

◆ CONNECT_HANDSHAKE

const char industrial::udp_socket::UdpSocket::CONNECT_HANDSHAKE = 142
staticprotected

udp socket connect handshake value

Definition at line 79 of file udp_socket.h.

◆ udp_read_buffer_

char industrial::udp_socket::UdpSocket::udp_read_buffer_[MAX_BUFFER_SIZE+1]
protected

Definition at line 81 of file udp_socket.h.

◆ udp_read_head_

char* industrial::udp_socket::UdpSocket::udp_read_head_
protected

Definition at line 82 of file udp_socket.h.

◆ udp_read_len_

size_t industrial::udp_socket::UdpSocket::udp_read_len_
protected

Definition at line 83 of file udp_socket.h.


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