Open Lighting Architecture: ola::plugin::kinet::UDPSocket Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Member Functions | List of all members
ola::plugin::kinet::UDPSocket Class Reference
Inheritance diagram for ola::plugin::kinet::UDPSocket:

## Public Member Functions
bool | Init ()
| Initialize the socket.
bool | Bind (const IPV4SocketAddress &endpoint)
| Bind this socket to an external address:port.
bool | GetSocketAddress (IPV4SocketAddress *address) const
| Return the local address this socket is bound to.
bool | Close ()
| Close the socket.
ola::io::DescriptorHandle | ReadDescriptor () const
| Returns the read descriptor for this socket.
ola::io::DescriptorHandle | WriteDescriptor () const
| Returns the write descriptor for this socket.
ssize_t | SendTo (const uint8_t *buffer, unsigned int size, const IPV4Address &ip, unsigned short port) const
| Send data on this UDPSocket.
ssize_t | SendTo (const uint8_t *buffer, unsigned int size, const IPV4SocketAddress &dest) const
| Send data on this UDPSocket.
ssize_t | SendTo (ola::io::IOVecInterface *data, const IPV4Address &ip, unsigned short port) const
| Send data from an IOVecInterface.
ssize_t | SendTo (ola::io::IOVecInterface *data, const IPV4SocketAddress &dest) const
| Send data from an IOVecInterface.
bool | RecvFrom (uint8_t *buffer, ssize_t *data_read) const
| Receive data.
bool | RecvFrom (uint8_t *buffer, ssize_t *data_read, IPV4Address &source) const
| Receive data.
bool | RecvFrom (uint8_t *buffer, ssize_t *data_read, IPV4Address &source, uint16_t &port) const
| Receive data and record the src address & port.
bool | RecvFrom (uint8_t *buffer, ssize_t *data_read, IPV4SocketAddress *source)
| Receive a datagram on the UDP Socket.
bool | EnableBroadcast ()
| Enable broadcasting for this socket.
bool | SetMulticastInterface (const IPV4Address &iface)
| Set the outgoing interface to be used for multicast transmission.
bool | JoinMulticast (const IPV4Address &iface, const IPV4Address &group, bool multicast_loop=false)
| Join a multicast group.
bool | LeaveMulticast (const IPV4Address &iface, const IPV4Address &group)
| Leave a multicast group.
bool | SetTos (uint8_t tos)
| Set the tos field for a socket.
Public Member Functions inherited from ola::io::BidirectionalFileDescriptor
void | SetOnData (ola::Callback0< void > *on_read)
| Set the callback to be run when data is available for reading.
void | SetOnWritable (ola::Callback0< void > *on_write)
| Set the callback to be run when the descriptor can be written to.
void | PerformRead ()
| Called when there is data available on the descriptor.
void | PerformWrite ()
| Called when the descriptor can be written to.
Public Member Functions inherited from ola::io::ReadFileDescriptor
bool | ValidReadDescriptor () const
| Check if this file descriptor is valid.
Public Member Functions inherited from ola::io::WriteFileDescriptor
bool | ValidWriteDescriptor () const
| Check if this file descriptor is valid.

## Member Function Documentation

## ◆ Bind()

bool ola::network::UDPSocket::Bind | ( | const IPV4SocketAddress & | endpoint | ) |
| virtual

Bind this socket to an external address:port.

Parameters

  endpoint | the local socket address to bind to.

Returns
  true if the bind succeeded, false if it failed.

Implements ola::network::UDPSocketInterface.

## ◆ Close()

bool ola::network::UDPSocket::Close | ( |  | ) |
| virtual

Close the socket.

Returns
  true if the call succeeded, false if it failed.

Implements ola::network::UDPSocketInterface.

## ◆ EnableBroadcast()

bool ola::network::UDPSocket::EnableBroadcast | ( |  | ) |
| virtual

Enable broadcasting for this socket.

Returns
  true if it worked, false otherwise

Implements ola::network::UDPSocketInterface.

## ◆ GetSocketAddress()

bool ola::network::UDPSocket::GetSocketAddress | ( | IPV4SocketAddress * | address | ) | const
| virtual

Return the local address this socket is bound to.

Parameters

  [out] | address | the local socket address this socket is bound to.

Returns
  true if the call succeeded, false if it failed.

Implements ola::network::UDPSocketInterface.

## ◆ Init()

bool ola::network::UDPSocket::Init | ( |  | ) |
| virtual

Initialize the socket.

Returns
  false if initialization failed.

Implements ola::network::UDPSocketInterface.

## ◆ JoinMulticast()

bool ola::network::UDPSocket::JoinMulticast | ( | const IPV4Address & | iface,
|  | const IPV4Address & | group,
|  | bool | multicast_loop = false )
| virtual

Join a multicast group.

Parameters

  iface | the address of the interface to use.
  group | the address of the group to join
  multicast_loop | enable multicast loop

Returns
  true if it worked, false otherwise

Implements ola::network::UDPSocketInterface.

## ◆ LeaveMulticast()

bool ola::network::UDPSocket::LeaveMulticast | ( | const IPV4Address & | iface,
|  | const IPV4Address & | group )
| virtual

Leave a multicast group.

Parameters

  iface | the address of the interface to use.
  group | the address of the group to join

Returns
  true if it worked, false otherwise

Implements ola::network::UDPSocketInterface.

## ◆ ReadDescriptor()

ola::io::DescriptorHandle ola::network::UDPSocket::ReadDescriptor | ( |  | ) | const
| inlinevirtual

Returns the read descriptor for this socket.

Returns
  the DescriptorHandle for this descriptor.

Implements ola::network::UDPSocketInterface.

## ◆ RecvFrom() [1/4]

bool ola::network::UDPSocket::RecvFrom | ( | uint8_t * | buffer,
|  | ssize_t * | data_read ) const
| virtual

Receive data.

Parameters

  buffer | the buffer to store the data
  data_read | the size of the buffer, updated with the number of bytes read

Returns
  true or false

Implements ola::network::UDPSocketInterface.

## ◆ RecvFrom() [2/4]

bool ola::network::UDPSocket::RecvFrom | ( | uint8_t * | buffer,
|  | ssize_t * | data_read,
|  | IPV4Address & | source ) const
| virtual

Receive data.

Parameters

  buffer | the buffer to store the data
  data_read | the size of the buffer, updated with the number of bytes read
  source | the src ip of the packet

Returns
  true or false

Deprecated
  Use the IPV4SocketAddress version instead.

Implements ola::network::UDPSocketInterface.

## ◆ RecvFrom() [3/4]

bool ola::network::UDPSocket::RecvFrom | ( | uint8_t * | buffer,
|  | ssize_t * | data_read,
|  | IPV4Address & | source,
|  | uint16_t & | port ) const
| virtual

Receive data and record the src address & port.

Parameters

  buffer | the buffer to store the data
  data_read | the size of the buffer, updated with the number of bytes read
  source | the src ip of the packet
  port | the src port of the packet in host byte order

Returns
  true or false

Deprecated
  Use the IPV4SocketAddress version instead.

Implements ola::network::UDPSocketInterface.

## ◆ RecvFrom() [4/4]

bool ola::network::UDPSocket::RecvFrom | ( | uint8_t * | buffer,
|  | ssize_t * | data_read,
|  | IPV4SocketAddress * | source )
| virtual

Receive a datagram on the UDP Socket.

Parameters

  buffer | the buffer to store the data
  data_read | the size of the buffer, updated with the number of bytes read
  source | the source of the datagram.

Returns
  true or false

Implements ola::network::UDPSocketInterface.

## ◆ SendTo() [1/4]

ssize_t ola::network::UDPSocket::SendTo | ( | const uint8_t * | buffer,
|  | unsigned int | size,
|  | const IPV4Address & | ip,
|  | unsigned short | port ) const
| virtual

Send data on this UDPSocket.

Parameters

  buffer | the data to send
  size | the length of the data
  ip | the IP to send to
  port | the port to send to in HOST byte order.

Returns
  the number of bytes sent.

Deprecated
  Use the IPV4SocketAddress version instead.

Implements ola::network::UDPSocketInterface.

## ◆ SendTo() [2/4]

ssize_t ola::network::UDPSocket::SendTo | ( | const uint8_t * | buffer,
|  | unsigned int | size,
|  | const IPV4SocketAddress & | dest ) const
| virtual

Send data on this UDPSocket.

Parameters

  buffer | the data to send
  size | the length of the data
  dest | the IP:Port to send the datagram to.

Returns
  the number of bytes sent

Implements ola::network::UDPSocketInterface.

## ◆ SendTo() [3/4]

ssize_t ola::network::UDPSocket::SendTo | ( | ola::io::IOVecInterface * | data,
|  | const IPV4Address & | ip,
|  | unsigned short | port ) const
| virtual

Send data from an IOVecInterface.

Parameters

  data | the IOVecInterface class to send.
  ip | the IP to send to
  port | the port to send to in HOST byte order.

Returns
  the number of bytes sent.

Deprecated
  Use the IPV4SocketAddress version instead.

This will try to send as much data as possible. If the data exceeds the MTU the UDP packet will probably get fragmented at the IP layer (depends on OS really). Try to avoid this.

Implements ola::network::UDPSocketInterface.

## ◆ SendTo() [4/4]

ssize_t ola::network::UDPSocket::SendTo | ( | ola::io::IOVecInterface * | data,
|  | const IPV4SocketAddress & | dest ) const
| virtual

Send data from an IOVecInterface.

Parameters

  data | the IOVecInterface class to send.
  dest | the IPV4SocketAddress to send to

Returns
  the number of bytes sent.

This will try to send as much data as possible. If the data exceeds the MTU the UDP packet will probably get fragmented at the IP layer (depends on OS really). Try to avoid this.

Implements ola::network::UDPSocketInterface.

## ◆ SetMulticastInterface()

bool ola::network::UDPSocket::SetMulticastInterface | ( | const IPV4Address & | iface | ) |
| virtual

Set the outgoing interface to be used for multicast transmission.

Parameters

  iface | the address of the interface to use.

Implements ola::network::UDPSocketInterface.

## ◆ SetTos()

bool ola::network::UDPSocket::SetTos | ( | uint8_t | tos | ) |
| virtual

Set the tos field for a socket.

Parameters

  tos | the tos field

Returns
  true if it worked, false otherwise

Implements ola::network::UDPSocketInterface.

## ◆ WriteDescriptor()

ola::io::DescriptorHandle ola::network::UDPSocket::WriteDescriptor | ( |  | ) | const
| inlinevirtual

Returns the write descriptor for this socket.

Returns
  the DescriptorHandle for this descriptor.

Implements ola::network::UDPSocketInterface.

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

- include/ola/network/Socket.h
- common/network/Socket.cpp