Goby3  3.1.5a
2024.05.23
goby::util::TCPClient Class Reference

provides a basic TCP client for line by line text based communications to a remote TCP server More...

#include <goby/util/linebasedcomms/tcp_client.h>

Inheritance diagram for goby::util::TCPClient:
goby::util::LineBasedInterface

Public Member Functions

 TCPClient (std::string server, unsigned port, const std::string &delimiter="\r\n", int retry_interval=10)
 create a TCPClient More...
 
 ~TCPClient () override
 
std::string local_endpoint () override
 string representation of the local endpoint (e.g. 192.168.1.105:54230) More...
 
std::string remote_endpoint () override
 string representation of the remote endpoint, (e.g. 192.168.1.106:50000) More...
 
- Public Member Functions inherited from goby::util::LineBasedInterface
 LineBasedInterface (const std::string &delimiter)
 
virtual ~LineBasedInterface ()
 
void start ()
 
void close ()
 
bool active ()
 
void sleep (int sec)
 
bool readline (std::string *s, AccessOrder order=OLDEST_FIRST)
 returns string line (including delimiter) More...
 
bool readline (protobuf::Datagram *msg, AccessOrder order=OLDEST_FIRST)
 
void write (const std::string &s)
 
void write (const protobuf::Datagram &msg)
 
void clear ()
 
void set_delimiter (const std::string &s)
 
std::string delimiter () const
 

Additional Inherited Members

- Public Types inherited from goby::util::LineBasedInterface
enum  AccessOrder { NEWEST_FIRST, OLDEST_FIRST }
 
- Protected Member Functions inherited from goby::util::LineBasedInterface
void set_active (bool active)
 
std::string & delimiter ()
 
std::deque< goby::util::protobuf::Datagram > & in ()
 
goby::middleware::InterThreadTransporterinterthread ()
 
int index ()
 
goby::middleware::DynamicGroupin_group ()
 
goby::middleware::DynamicGroupout_group ()
 
bool io_thread_ready ()
 

Detailed Description

provides a basic TCP client for line by line text based communications to a remote TCP server

Definition at line 43 of file tcp_client.h.

Constructor & Destructor Documentation

◆ TCPClient()

goby::util::TCPClient::TCPClient ( std::string  server,
unsigned  port,
const std::string &  delimiter = "\r\n",
int  retry_interval = 10 
)

create a TCPClient

Parameters
serverdomain name or IP address of the remote server
portport of the remote server
delimiterstring used to split lines
retry_intervalTime between reconnects in seconds

◆ ~TCPClient()

goby::util::TCPClient::~TCPClient ( )
override

Member Function Documentation

◆ local_endpoint()

std::string goby::util::TCPClient::local_endpoint ( )
inlineoverridevirtual

string representation of the local endpoint (e.g. 192.168.1.105:54230)

Implements goby::util::LineBasedInterface.

Definition at line 57 of file tcp_client.h.

◆ remote_endpoint()

std::string goby::util::TCPClient::remote_endpoint ( )
inlineoverridevirtual

string representation of the remote endpoint, (e.g. 192.168.1.106:50000)

Reimplemented from goby::util::LineBasedInterface.

Definition at line 62 of file tcp_client.h.


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