You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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, then available returns -1 and the last error is "connection reset by peer". I suspect this is from the recvfrom call within available. If I change this to use the IP of a remote machine as the remote address, poll properly times out and returns false after sendBytes.
To Reproduce
#include<iostream>voidDatagramSocketTest::testLocalIPIssue()
{
DatagramSocket socket(SocketAddress("127.0.0.1", 0), true, true);
socket.connect(SocketAddress("127.0.0.1", 2345));
unsignedchar values[5]{};
socket.sendBytes(values, 5);
Poco::Timespan timeout(5000);
if (socket.poll(timeout, Socket::SELECT_READ))
{
std::cout << socket.available(); // -1 and last error is "connection reset by peer"
}
}
Expected behavior
Poll returns false, just like it would when local and remote IPs don't match.
Please add relevant environment information:
Windows 10
POCO 1.12.5
The text was updated successfully, but these errors were encountered:
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.
andrewauclair
changed the title
Socket::poll returns true after sending to local UDP socket that is not connected
Socket::available Causes Connection Reset by Peer on Windows UDP Sockets
Apr 25, 2024
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:
The text was updated successfully, but these errors were encountered: