BoB robotics
The Brains on Board robotics library
BoBRobotics::Net::Client Class Reference

General-purpose TCP client. More...

#include <client.h>

Inheritance diagram for BoBRobotics::Net::Client:
BoBRobotics::Net::Connection BoBRobotics::Threadable

Public Member Functions

 Client (const std::string &host=getDefaultIP(), uint16_t port=DefaultListenPort)
 Create client and connect to host over TCP.
 
const std::string & getIP () const
 
- Public Member Functions inherited from BoBRobotics::Net::Connection
template<typename... Ts>
 Connection (Ts &&... args)
 Default listening port.
 
bool isOpen () const
 
void setCommandHandler (const std::string &commandName, const CommandHandler &handler)
 Add a handler for a specified type of command. More...
 
void read (void *buffer, size_t length)
 Read a specified number of bytes into a buffer.
 
SocketWriter getSocketWriter ()
 Return a transaction object for writing to this Connection's Socket.
 
std::string readNextCommand ()
 
- Public Member Functions inherited from BoBRobotics::Threadable
virtual void run ()
 Run on the current thread, blocking until process ends.
 
virtual bool isRunning ()
 Check if the run() function has been called.
 
virtual void runInBackground ()
 Run the process on a background thread.
 
virtual void stop ()
 Stop the background thread.
 

Static Public Member Functions

static std::string getDefaultIP ()
 

Additional Inherited Members

- Static Public Attributes inherited from BoBRobotics::Net::Connection
static constexpr size_t DefaultBufferSize = 1024 * 8
 
static constexpr int DefaultListenPort = 2000
 Default buffer size, in bytes.
 
- Protected Member Functions inherited from BoBRobotics::Net::Connection
SocketgetSocket ()
 
virtual void runInternal () override
 
virtual void runInternal ()=0
 

Detailed Description

General-purpose TCP client.

To be used with corresponding Server object. Various sink/source-type objects are used for either sending or receiving data from the server.


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