Class UdpSocket

Inheritance Relationships

Base Type

Class Documentation

class UdpSocket : public visionary::ITransport

Public Functions

UdpSocket()
int connect(const std::string &hostname, uint16_t port)
int bindPort(std::uint16_t port)
int shutdown()
virtual int send(const std::vector<std::uint8_t> &buffer) override

Send data on socket to device

All bytes are sent on the socket. It is regarded as error if this is not possible.

Parameters:

buffer[in] buffer containing the bytes that shall be sent.

Returns:

OS error code.

virtual int recv(std::vector<std::uint8_t> &buffer, std::size_t maxBytesToReceive) override

Receive data on socket to device

Receive at most maxBytesToReceive bytes.

Parameters:
  • buffer[in] buffer containing the bytes that shall be sent.

  • maxBytesToReceive[in] maximum number of bytes to receive.

Returns:

number of received bytes, negative values are OS error codes.

virtual int read(std::vector<std::uint8_t> &buffer, std::size_t nBytesToReceive) override

Read a number of bytes

Contrary to recv this method reads precisely nBytesToReceive bytes.

Parameters:
  • buffer[in] buffer containing the bytes that shall be sent.

  • maxBytesToReceive[in] maximum number of bytes to receive.

Returns:

number of received bytes, negative values are OS error codes.