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

A class for operating on sockets in a platform-independent way. More...

#include <socket.h>

Public Member Functions

 Socket (const socket_t handle)
 
 Socket (int domain, int type, int protocol)
 
void close ()
 Close the socket.
 
bool isOpen () const
 Check if socket is still open.
 
socket_t getHandle () const
 Get the current socket handle this object holds.
 
size_t read (void *buffer, const size_t length)
 
void send (const void *buffer, size_t length)
 Send a buffer of specified length through the socket.
 
void send (const std::string &msg)
 Send a string over the socket.
 
 Socket (Socket &&old) noexcept
 

Detailed Description

A class for operating on sockets in a platform-independent way.

In Windows, this class represents an underlying SOCKET pointer and in *nix, it represents a socket's file handle. This class provides convenience methods for sending and receiving data from the socket.

A typical (plaintext) command sent over a socket looks like this: TNK 0.5 0.5 where the first word indicates the command name and the other words are parameters.


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