Class SocketReceive
Defined in File SocketReceive.h
Inheritance Relationships
Derived Types
public ska::pst::recv::IBVQueue
(Class IBVQueue)public ska::pst::recv::UDPSocketReceive
(Class UDPSocketReceive)
Class Documentation
-
class SocketReceive
Provides implementation of a standard UDP socket for receiving UDP packets. Abstracts the complexity of interacting with linux socket libraries.
Subclassed by ska::pst::recv::IBVQueue, ska::pst::recv::UDPSocketReceive
Public Functions
-
SocketReceive() = default
Construct a new SocketReceive object.
-
virtual ~SocketReceive() = default
Destroy the SocketReceive object.
-
virtual void allocate_resources(size_t bufsz, size_t packet_size) = 0
Allocate memory resources for the receiving socket.
- Parameters
bufsz – size of the receiving buffer in bytes
packet_size – size of each UDP packet payload in bytes
-
virtual void configure(const std::string &ip_address, int port) = 0
Configure the receiving socket at the specified endpoint. Opens the socket on the interface associated with the specified address, or if “any” is specified, listen on any interface.
- Parameters
ip_address – IPv4 address for receiving UDP socke
port – Port number for the UDP socket.
-
virtual void deconfigure_beam() = 0
Release all resources.
-
virtual size_t clear_buffered_packets() = 0
Discard all packets that are waiting in the receiving sockets ingest stream.
- Returns
size_t number of bytes cleared.
-
virtual int acquire_packet() = 0
Receive a single UDP packet. If the previously received packet was not consumed via consume_packet, then no packet is received. If the socket is blocking, this method will block until a packet is received. If the socket is non-blocking, this method will busy-wait until a packet is received. In the latter case, the busy-wait may be interrupted by setting SocketReceiver::keep_receiving to false.
- Returns
packet slot index of the acquired packet, less than 0 indicates error
-
virtual void release_packet(int index) = 0
Release the most recently received packet.
- Parameters
index – slot
-
inline bool still_receiving()
Return the value of SocketReceiver::keep_receiving.
- Returns
true
- Returns
false
-
virtual uint64_t process_sleeps() = 0
Return the number of accumulated sleeps, resetting the internal counter to 0.
- Returns
uint64_t Number of accumulated sleeps since last reset.
-
virtual char *get_buf_ptr(int slot_index) = 0
Return a pointer to the packet that is received in the specified slot.
- Parameters
slot_index –
- Returns
char *
Public Static Attributes
-
static bool keep_receiving
Global flag to cease receiving.
-
SocketReceive() = default