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

#include <UdpSocket.h>

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

Public Member Functions

int connect (const std::string &ipaddr, std::uint16_t port)
 
int getLastError () override
 
recv_return_t read (ByteBuffer &buffer, std::size_t nBytesToReceive) override
 
recv_return_t recv (ByteBuffer &buffer, std::size_t maxBytesToReceive) override
 
send_return_t send (const char *pData, size_t size) override
 
virtual send_return_t send (const char *pData, size_t size)=0
 
template<typename T >
send_return_t send (const std::vector< T > &buffer)
 
int shutdown () override
 
 UdpSocket ()
 
virtual ~UdpSocket ()
 
- Public Member Functions inherited from visionary::ITransport
template<typename T >
send_return_t send (const std::vector< T > &buffer)
 
virtual ~ITransport ()=default
 

Private Attributes

std::unique_ptr< SockAddrInm_pSockAddrIn
 
std::unique_ptr< SockRecordm_pSockRecord
 

Friends

class Conv
 

Additional Inherited Members

- Public Types inherited from visionary::ITransport
using ByteBuffer = std::vector< std::uint8_t >
 
using recv_return_t = ssize_t
 
using send_return_t = ssize_t
 

Detailed Description

Definition at line 19 of file UdpSocket.h.

Constructor & Destructor Documentation

◆ UdpSocket()

visionary::UdpSocket::UdpSocket ( )

Definition at line 40 of file UdpSocket.cpp.

◆ ~UdpSocket()

visionary::UdpSocket::~UdpSocket ( )
virtual

Definition at line 44 of file UdpSocket.cpp.

Member Function Documentation

◆ connect()

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

connect to a peer via UDP

actually UDP is connectionless, so this method just stored the target address and uses thestored adresse for successive calls to send, \ recv and read.

Parameters
[in]ipaddrstring representation of the device ip address ("xx.xx.xx.xx")
[in]portnumber of the device port to connect to (in host byte order)
Return values
0connect successful (in this case: the socket could be created)
-1connect failed (in this case: no socket could be created or the ip address format is invalid)

Definition at line 52 of file UdpSocket.cpp.

◆ getLastError()

int visionary::UdpSocket::getLastError ( )
overridevirtual

Implements visionary::ITransport.

Definition at line 192 of file UdpSocket.cpp.

◆ read()

ITransport::recv_return_t visionary::UdpSocket::read ( ByteBuffer 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]nBytesToReceivemaximum number of bytes to receive.
Returns
number of received bytes or (-1) on error

Implements visionary::ITransport.

Definition at line 164 of file UdpSocket.cpp.

◆ recv()

ITransport::recv_return_t visionary::UdpSocket::recv ( ByteBuffer 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 or (-1) on error

Implements visionary::ITransport.

Definition at line 146 of file UdpSocket.cpp.

◆ send() [1/3]

ITransport::send_return_t visionary::UdpSocket::send ( const char *  pData,
size_t  size 
)
overridevirtual

Implements visionary::ITransport.

Definition at line 135 of file UdpSocket.cpp.

◆ send() [2/3]

virtual send_return_t visionary::ITransport::send

◆ send() [3/3]

template<typename T >
send_return_t visionary::ITransport::send ( typename T  )
inline

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
Number of bytes sent or (-1) on error

Definition at line 45 of file ITransport.h.

◆ shutdown()

int visionary::UdpSocket::shutdown ( )
overridevirtual

Implements visionary::ITransport.

Definition at line 119 of file UdpSocket.cpp.

Friends And Related Function Documentation

◆ Conv

friend class Conv
friend

Definition at line 21 of file UdpSocket.h.

Member Data Documentation

◆ m_pSockAddrIn

std::unique_ptr<SockAddrIn> visionary::UdpSocket::m_pSockAddrIn
private

Definition at line 49 of file UdpSocket.h.

◆ m_pSockRecord

std::unique_ptr<SockRecord> visionary::UdpSocket::m_pSockRecord
private

Definition at line 48 of file UdpSocket.h.


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


sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 04:38:18