Open errorxyz opened 1 month ago
The behaviour seems consistent with Linux, no?
recv function failed: Os { code: 111, kind: ConnectionRefused, message: "Connection refused" }
The behaviour seems consistent with Linux, no?
Yes, I can confirm this behaviour with linux as well. I had stumbled upon this issue while working with tokio::net::UdpSocket
which does not have this issue on linux and I presumed it to be the case with std::net::UdpSocket
as well. Thanks for pointing it out
man 7 udp:
Error handling All fatal errors will be passed to the user as an error return even when the socket is not connected. This includes asynchronous errors received from the network. You may get an error for an earlier packet that was sent on the same socket. This behavior differs from many other BSD socket implementations which don't pass any errors unless the socket is connected. Linux's behavior is mandated by RFC 1122.
So this likely stems from an ICMP error reply to the send that couldn't be delivered. If you don't connect the socket and use send_to / recv_from instead then this shouldn't happen and the errors would only be visible in the auxiliary error queue.
If you don't connect the socket and use send_to / recv_from instead then this shouldn't happen and the errors would only be visible in the auxiliary error queue.
I still do get the error
Trying to
recv()
on aUdpSocket
after asend()
to a closed UDP socket failsI tried this code:
I expected to see this happen: We should be able to
recv()
without any errorInstead, this happened:
recv()
failsGolang currently handles this using
SIO_UDP_CONNRESET
here: https://github.com/golang/go/blob/e8c5bed7ea43e1a533c322e6b928ed06327721db/src/internal/poll/fd_windows.go#L340-L351Meta
rustc --version --verbose
:Backtrace
``` recv function failed: Os { code: 10054, kind: ConnectionReset, message: "An existing connection was forcibly closed by the remote host." } ```