Skip to content

add send_queue() for udp::Socket? #838

Closed
@phire

Description

@phire

tcp::Socket has a send_queue() method to check the status of tx_buffer (which can be used to implement flush), but udp::Socket is missing any equivalent functionality to check tx_buffer status (except for can_send)

My usecase:
I want to create a UDP socket, send a packet to a broadcast address, and then immediately destroy the socket. The same memory is reused to create TCP socket and listen for an incoming connection. This loops after a timeout, destroying the TCP socket to reuse the memory for a UDP socket.

There is no sane way to implement this with the current api, as dropping or closing the UDP socket too soon drops any unsent packets before they even reach the network driver. Yes, I know that delivery of UDP packets isn't meant to be reliable, but this results in zero packets being delivered.
The only workaround is to insert a sleep before destroying the UDP socket and hope it's the delay is long enough to allow for transmission, but I'd rather not do that.

If send_queue() was added to udp::Socket, then I could flush it just like a TCP socket before dropping.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions