Public Member Functions | Private Member Functions | Private Attributes | List of all members
visionary::UdpSocket Class Reference

#include <UdpSocket.h>

Inheritance diagram for visionary::UdpSocket:
Inheritance graph
[legend]

Public Member Functions

int bindPort (std::uint16_t port)
 
int connect (const std::string &hostname, uint16_t port)
 
int read (std::vector< std::uint8_t > &buffer, std::size_t nBytesToReceive) override
 
int recv (std::vector< std::uint8_t > &buffer, std::size_t maxBytesToReceive) override
 
int send (const std::vector< std::uint8_t > &buffer) override
 
int shutdown ()
 
 UdpSocket ()
 
- Public Member Functions inherited from visionary::ITransport
virtual ~ITransport ()
 

Private Member Functions

int initSocket ()
 

Private Attributes

SOCKET m_socket
 
struct sockaddr_in m_udpAddr
 

Detailed Description

Definition at line 50 of file UdpSocket.h.

Constructor & Destructor Documentation

◆ UdpSocket()

visionary::UdpSocket::UdpSocket ( )

Definition at line 28 of file UdpSocket.cpp.

Member Function Documentation

◆ bindPort()

int visionary::UdpSocket::bindPort ( std::uint16_t  port)

Definition at line 97 of file UdpSocket.cpp.

◆ connect()

int visionary::UdpSocket::connect ( const std::string &  hostname,
uint16_t  port 
)

Definition at line 75 of file UdpSocket.cpp.

◆ initSocket()

int visionary::UdpSocket::initSocket ( )
private

Definition at line 34 of file UdpSocket.cpp.

◆ read()

int visionary::UdpSocket::read ( std::vector< std::uint8_t > &  buffer,
std::size_t  nBytesToReceive 
)
overridevirtual

Read a number of bytes

Contrary to recv this method reads precisely nBytesToReceive bytes.

Parameters
[in]bufferbuffer containing the bytes that shall be sent.
[in]maxBytesToReceivemaximum number of bytes to receive.
Returns
number of received bytes, negative values are OS error codes.

Implements visionary::ITransport.

Definition at line 157 of file UdpSocket.cpp.

◆ recv()

int visionary::UdpSocket::recv ( std::vector< std::uint8_t > &  buffer,
std::size_t  maxBytesToReceive 
)
overridevirtual

Receive data on socket to device

Receive at most maxBytesToReceive bytes.

Parameters
[in]bufferbuffer containing the bytes that shall be sent.
[in]maxBytesToReceivemaximum number of bytes to receive.
Returns
number of received bytes, negative values are OS error codes.

Implements visionary::ITransport.

Definition at line 148 of file UdpSocket.cpp.

◆ send()

int visionary::UdpSocket::send ( const std::vector< std::uint8_t > &  buffer)
overridevirtual

Send data on socket to device

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

Parameters
[in]bufferbuffer containing the bytes that shall be sent.
Returns
OS error code.

Implements visionary::ITransport.

Definition at line 137 of file UdpSocket.cpp.

◆ shutdown()

int visionary::UdpSocket::shutdown ( )

Definition at line 124 of file UdpSocket.cpp.

Member Data Documentation

◆ m_socket

SOCKET visionary::UdpSocket::m_socket
private

Definition at line 64 of file UdpSocket.h.

◆ m_udpAddr

struct sockaddr_in visionary::UdpSocket::m_udpAddr
private

Definition at line 65 of file UdpSocket.h.


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


sick_safevisionary_base
Author(s):
autogenerated on Sat Oct 21 2023 02:24:26