pub struct EventSocket { /* private fields */ }Expand description
A GVCP message channel: the socket a device sends its events to.
Binding starts a receive thread. It acknowledges each message as it
arrives, whether or not the application is reading, and queues its
events for recv, up to EVENT_QUEUE_CAPACITY; past
that the oldest is dropped, counted in EventStats::dropped and
logged. A device whose acknowledgement does not come resends the message
every GevMCTT and holds back the events behind it: an Allied Vision
Manta G-125B (GevMCTT 100 ms) sent one ExposureEnd twelve times to an
application that read a second late when the acknowledgement waited for
the read, and, left unread for ten seconds, kept 44 events and sent
EventOverflow for the rest.
A retransmission repeats the request id and the bytes of the message before it; it is acknowledged again and its events are not queued twice. Distinct events under one request id are each queued. Dropping the socket stops the thread within one tick.
Implementations§
Source§impl EventSocket
impl EventSocket
Sourcepub async fn bind(local_ip: IpAddr, port: u16) -> Result<Self>
pub async fn bind(local_ip: IpAddr, port: u16) -> Result<Self>
Bind a GVCP message socket on the provided local address and start its receive thread.
Sourcepub async fn recv(&self) -> Result<EventPacket>
pub async fn recv(&self) -> Result<EventPacket>
The next event, waiting until one arrives. Events come in the order the device sent them; a datagram carrying several is queued whole.
Cancel-safe: an event is taken only by the poll that returns it. Concurrent callers are symmetric consumers of one queue. An error once the receive thread has failed, after the events it queued.
Sourcepub fn stats(&self) -> EventStats
pub fn stats(&self) -> EventStats
What the receive thread has counted so far.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Return the local address bound to the socket.