Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
industrial::tcp_server::TcpServer Class Reference

Defines TCP server functions. More...

#include <tcp_server.h>

Inheritance diagram for industrial::tcp_server::TcpServer:
Inheritance graph
[legend]

Public Member Functions

bool init (int port_num)
 initializes TCP server socket. The connect method must be called following initialization in order to communicate with the remote host. More...
 
bool makeConnect ()
 connects to the remote host More...
 
 TcpServer ()
 Constructor. More...
 
 ~TcpServer ()
 Destructor. More...
 
- Public Member Functions inherited from industrial::tcp_socket::TcpSocket
 TcpSocket ()
 
virtual ~TcpSocket ()
 
- 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 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

int getSrvrHandle () const
 
void setSrvrHandle (int srvr_handle_)
 
- 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)
 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

int srvr_handle_
 server handle. Every time a connection is made, the class generates a new handle for sending/receiving. The server handle is saved off to a separate variable so that recoving a lost connection is possible. More...
 
- 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...
 

Additional Inherited Members

- 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 = 1000
 socket ready polling timeout (ms) More...
 

Detailed Description

Defines TCP server functions.

Definition at line 49 of file tcp_server.h.

Constructor & Destructor Documentation

industrial::tcp_server::TcpServer::TcpServer ( )

Constructor.

Definition at line 44 of file tcp_server.cpp.

industrial::tcp_server::TcpServer::~TcpServer ( )

Destructor.

Definition at line 51 of file tcp_server.cpp.

Member Function Documentation

int industrial::tcp_server::TcpServer::getSrvrHandle ( ) const
inlineprotected

Definition at line 84 of file tcp_server.h.

bool industrial::tcp_server::TcpServer::init ( int  port_num)

initializes TCP server socket. The connect method must be called following initialization in order to communicate with the remote host.

Parameters
port_numport number (server & client port number must match)
Returns
true on success, false otherwise (socket is invalid)

Definition at line 57 of file tcp_server.cpp.

bool industrial::tcp_server::TcpServer::makeConnect ( )
virtual

connects to the remote host

Returns
true on success, false otherwise

Implements industrial::smpl_msg_connection::SmplMsgConnection.

Definition at line 118 of file tcp_server.cpp.

void industrial::tcp_server::TcpServer::setSrvrHandle ( int  srvr_handle_)
inlineprotected

Definition at line 89 of file tcp_server.h.

Member Data Documentation

int industrial::tcp_server::TcpServer::srvr_handle_
protected

server handle. Every time a connection is made, the class generates a new handle for sending/receiving. The server handle is saved off to a separate variable so that recoving a lost connection is possible.

Definition at line 82 of file tcp_server.h.


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


simple_message
Author(s): Shaun Edwards
autogenerated on Sat Sep 21 2019 03:30:09