Open andrewauclair opened 2 months ago
Should we be using Poco::Net::UDPServer
and Poco::Net::UDPClient
instead of a Poco::Net::DatagramSocket
directly to avoid issues like this?
Maybe not. Looks like that only supports connecting locally.
I ended up closing and reopening the socket if there was an error after calling available()
. It still doesn't seem that great to me that available()
could cause an error and return -1.
Some additional testing resulted in receiveBytes
throwing a std::bad_array_new_length
because available
returned -1.
Describe the bug Created a DatagramSocket with local address 127.0.0.1:0 and remote address 127.0.0.1:2345. After calling
sendBytes
on this UDP socket,poll
returns true, thenavailable
returns -1 and the last error is "connection reset by peer". I suspect this is from therecvfrom
call withinavailable
. If I change this to use the IP of a remote machine as the remote address, poll properly times out and returns false aftersendBytes
.To Reproduce
Expected behavior Poll returns false, just like it would when local and remote IPs don't match.
Please add relevant environment information: