17#ifndef STAUBLI_ROBOT_DRIVER__COMMUNICATION__SOCKET_HPP_
18#define STAUBLI_ROBOT_DRIVER__COMMUNICATION__SOCKET_HPP_
58 const std::string& remote_address, uint16_t remote_port, uint16_t local_port) = 0;
69 const std::string& remote_address, uint16_t remote_port,
70 const std::string& local_address, uint16_t local_port) = 0;
89 virtual bool send(std::vector<uint8_t>& data) = 0;
100 virtual bool receive_once(
int timeout_ms, std::vector<uint8_t>& data) = 0;
109 std::vector<uint8_t>& ,
110 size_t )> reception_callback) = 0;
Factory for creating communication interfaces.
Definition socket.hpp:128
static std::shared_ptr< Socket > create(ProtocolType type)
Create a communication interface.
ProtocolType
Communication protocol types.
Definition socket.hpp:133
@ TCP
TCP socket communication.
@ UDP
UDP socket communication.
Abstract interface for communication with the robot.
Definition socket.hpp:38
virtual bool connect(const std::string &remote_address, uint16_t remote_port, const std::string &local_address, uint16_t local_port)=0
Connect to the remote endpoint with specific local address.
virtual bool receive_once(int timeout_ms, std::vector< uint8_t > &data)=0
Receive data from socket (blocking with timeout)
virtual bool is_receiving() const =0
Check if the receive thread is running.
Socket()=default
Default constructor.
virtual bool start_receive_thread(std::function< void(std::vector< uint8_t > &, size_t)> reception_callback)=0
Start a receive thread that calls the provided reception_callback when data is received.
virtual bool send(std::vector< uint8_t > &data)=0
Send data to the remote endpoint.
virtual ~Socket()=default
Virtual destructor.
virtual bool connect(const std::string &remote_address, uint16_t remote_port, uint16_t local_port)=0
Connect to the remote endpoint.
virtual bool disconnect()=0
Disconnect from the remote endpoint.
virtual bool is_connected() const =0
Check if the connection is established.
virtual bool stop_receive_thread()=0
Stop the receive thread.
Definition messages.hpp:23
constexpr size_t MAX_SOCKET_PACKET_SIZE
Maximum packet size (bytes) for socket communication.
Definition socket.hpp:30