Server
For conceptual usage, see:
Implementation
This Python API is provided by a Rogue C++ class exported into Python.
Native C++ class: - Server
Generated API
- class rogue.protocols.udp.Server(port, jumbo)
C++:
rogue::protocols::udp::ServerBinding source: [Server.cpp]
UDP stream endpoint that listens on a local UDP port.
Servercombines UDP transport (udp::Core) with Rogue stream interfaces:stream::Slave: accepts outbound frames and transmits datagrams to the most recently seen remote endpoint.stream::Master: emits inbound datagrams as Rogue frames. A background receive thread listens on the bound UDP socket, forwards payloads as frames, and updates remote endpoint address when packets are received.
- __init__(port, jumbo)
C++:
rogue::protocols::udp::ServerConstructs a UDP server endpoint.
This constructor is a low-level C++ allocation path. Prefer
create()when shared ownership or Python exposure is required. Creates and binds UDP socket, initializes frame pool sizing, and starts background receive thread. Ifport == 0, the OS-assigned port is queried and stored.- Parameters:
port – Local UDP port to bind (0 requests dynamic port assignment).
jumbo –
truefor jumbo payload sizing;falsefor standard MTU.
- getPort()
C++:
rogue::protocols::udp::Server::getPort()Returns bound local UDP port number.
- Returns:
Local UDP port.
- maxPayload()
C++:
rogue::protocols::udp::Core::maxPayload()Returns maximum UDP payload size in bytes.
Returns:
8972bytes when jumbo mode is enabled (MTU 9000).1472bytes when jumbo mode is disabled (MTU 1500).
- Returns:
Maximum payload size for configured MTU mode.
- setRxBufferCount(count)
C++:
rogue::protocols::udp::Core::setRxBufferCount()Requests kernel UDP receive-buffer sizing by packet count.
Computes
count * mtubytes and programsSO_RCVBUF. Returnsfalseif the kernel effective receive buffer is smaller than requested.- Parameters:
count – Number of packets worth of RX buffering to request.
- Returns:
trueif effective buffer size meets/exceeds request.
- setTimeout(timeout)
C++:
rogue::protocols::udp::Core::setTimeout()Sets outbound transmit wait timeout.
Timeout is specified in microseconds and converted to
timevalforselect()-based write readiness checks in derived endpoints.- Parameters:
timeout – Timeout in microseconds.
- _addSlave(slave)
C++:
rogue::interfaces::stream::Master::addSlave()Attaches a downstream slave.
Multiple slaves are supported. The first attached slave is used for frame allocation and receives frames last during send. Exposed as
_addSlave()in Python.- Parameters:
slave – Stream slave pointer.
- _slaveCount()
C++:
rogue::interfaces::stream::Master::slaveCount()Returns the number of attached slaves.
Exposed as
_slaveCount()in Python.- Returns:
Number of attached slaves.
- _reqFrame(size, zeroCopyEn)
C++:
rogue::interfaces::stream::Master::reqFrame()Requests allocation of a new frame from the primary slave.
Creates an empty frame with at least the requested payload capacity. The Master will forward this request to the primary Slave object. The request for a new Frame includes a flag which indicates if a zeroCopy frame is allowed. In most cases this flag can be set to
true. Non-zero-copy frames are requested if the Master may need to transmit the same frame multiple times. Exposed as_reqFrame()in Python.- Parameters:
size – Minimum requested payload size in bytes.
zeroCopyEn – Set to
truewhen zero-copy frame allocation is allowed.
- Returns:
Newly allocated frame pointer.
- _sendFrame(frame)
C++:
rogue::interfaces::stream::Master::sendFrame()Sends a frame to all attached slaves.
This method sends the passed Frame to all of the attached Slave objects by calling their acceptFrame() method. First the secondary Slaves are called in order of attachment, followed last by the primary Slave. If the Frame is a zero copy frame it will most likely be empty when the sendFrame() method returns Exposed as
_sendFrame()in Python.- Parameters:
frame – Frame to send.
- _stop()
C++:
rogue::interfaces::stream::Master::stop()Stops frame generation and shuts down associated threads.
Exposed as
stop()in Python. This is the primary subclass hook onMaster. Override when the subclass owns background activity or transport resources that require deterministic shutdown.
- __rshift__(other)
C++:
rogue::interfaces::stream::Master::rshiftPy()Supports
>>operator usage from Python.- Parameters:
p – Python object expected to resolve to a stream
Slave.- Returns:
Original Python object for chaining semantics.
- setDebug(debug, name)
C++:
rogue::interfaces::stream::Slave::setDebug()Sets debug message verbosity and logger name.
This method enables debug messages when using the base Slave class attached as a primary or secondary Slave on a Master. Typically used when attaching a base Slave object for debug purposes. Exposed as
setDebug()in Python.- Parameters:
debug – Maximum number of bytes to print in debug message.
name – Name included in debug messages.
- _acceptFrame(frame)
C++:
rogue::interfaces::stream::Slave::acceptFrame()Accepts a frame from an upstream master.
Invokes the Python override when provided.
- Parameters:
frame – Frame received from the stream path.
- getFrameCount()
C++:
rogue::interfaces::stream::Slave::getFrameCount()Returns frame counter.
Returns the total frames received. Only valid if acceptFrame is not re-implemented as a sub-class. Typically used when attaching a base Slave object for debug purposes. Exposed as
getFrameCount()in Python.- Returns:
Total number of Frame objects received.
- getByteCount()
C++:
rogue::interfaces::stream::Slave::getByteCount()Returns byte counter.
Returns the total bytes received. Only valid if acceptFrame is not re-implemented as a sub-class. Typically used when attaching a base Slave object for debug purposes. Exposed as
getByteCount()in Python.- Returns:
Total number of bytes received.
- _stop()
C++:
rogue::interfaces::stream::Slave::stop()Shuts down threads associated with this object.
Called during shutdown to stop activity and allow clean process exit. Subclasses should override when they own worker threads or timers. Exposed as
stop()in Python.
- getAllocCount()
C++:
rogue::interfaces::stream::Pool::getAllocCount()Returns total currently allocated buffer count.
This value is incremented as buffers are allocated and decremented as buffers are freed. Exposed as
getAllocCount()in Python.- Returns:
Total currently allocated buffers.
- getAllocBytes()
C++:
rogue::interfaces::stream::Pool::getAllocBytes()Returns total currently allocated bytes.
This value is incremented as buffers are allocated and decremented as buffers are freed. Exposed as
getAllocBytes()in Python.- Returns:
Total currently allocated bytes.
- setFixedSize(size)
C++:
rogue::interfaces::stream::Pool::setFixedSize()Sets fixed-size mode.
This method puts the allocator into fixed size mode. Exposed as
setFixedSize()in Python.- Parameters:
size – Fixed size value.
- getFixedSize()
C++:
rogue::interfaces::stream::Pool::getFixedSize()Returns fixed-size allocation setting.
A return value of
0means fixed-size mode is disabled. Exposed asgetFixedSize()in Python.- Returns:
Fixed size value or
0when fixed-size mode is disabled.
- setPoolSize(size)
C++:
rogue::interfaces::stream::Pool::setPoolSize()Sets buffer pool size. Exposed as
setPoolSize()in Python.- Parameters:
size – Number of entries to keep in the pool.
- getPoolSize()
C++:
rogue::interfaces::stream::Pool::getPoolSize()Returns configured maximum number of cached pool entries. Exposed as
getPoolSize()in Python.- Returns:
Pool size.
- __lshift__(other)
C++:
rogue::interfaces::stream::Slave::lshiftPy()Supports
<<operator usage from Python.- Parameters:
p – Python object expected to resolve to a stream
Master.- Returns:
Original Python object for chaining semantics.