Goby3  3.1.4
2024.02.22
goby::util::TCPServer Class Reference

provides a basic TCP server for line by line text based communications to a one or more remote TCP clients More...

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

Inheritance diagram for goby::util::TCPServer:
goby::util::LineBasedInterface

Public Member Functions

 TCPServer (unsigned port, const std::string &delimiter="\r\n")
 create a TCP server More...
 
 ~TCPServer () override
 
std::string local_endpoint () override
 string representation of the local endpoint (e.g. 192.168.1.105:54230) More...
 
const std::set< middleware::protobuf::TCPEndPoint > & remote_endpoints ()
 
- 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
virtual std::string remote_endpoint ()
 
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 server for line by line text based communications to a one or more remote TCP clients

Definition at line 43 of file tcp_server.h.

Constructor & Destructor Documentation

◆ TCPServer()

goby::util::TCPServer::TCPServer ( unsigned  port,
const std::string &  delimiter = "\r\n" 
)

create a TCP server

Parameters
portport of the server (use 50000+ to avoid problems with special system ports)
delimiterstring used to split lines

◆ ~TCPServer()

goby::util::TCPServer::~TCPServer ( )
override

Member Function Documentation

◆ local_endpoint()

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

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

Implements goby::util::LineBasedInterface.

Definition at line 54 of file tcp_server.h.

◆ remote_endpoints()

const std::set<middleware::protobuf::TCPEndPoint>& goby::util::TCPServer::remote_endpoints ( )
inline

Definition at line 59 of file tcp_server.h.


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