T
Terry
It's my understanding of UDP sockets that if there is a thread blocked on a
"recvFrom()" call and other thread sends a UDP packet to some address, that
if the machine on the other end isn't up, that the "recvFrom()" call should
just continue blocking. Right?
What I'm seeing is that when I send a packet to a particular address that is
not responding, my "recvFrom()" call throws an exception. I get "An
existing connection was forcibly closed by the remote host". It shouldn't
do that, right? UDP is connectionless, so if the machine on the other end
isn't running (well, I assume it's not running) it should just continue
blocking right?
Here's the basics of the code. I create the socket.
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
_socket.Bind(new IPEndPoint(IPAddress.Any, 1400) );
Then I spawn two threads, one for reading, one for sending:
_readThread = new Thread(new ThreadStart(read) );
_readThread.Start();
_sendThread = new Thread(new ThreadStart(send) );
_sendThread.Start();
The read thread just blocks on a "recvFrom()" until it gets data (or in this
case throws the above exception). The sending thread has a list of IPs it
needs to send requests to. It may or may not get a response to the request.
Why would I be getting a "connection closed" exception on a UDP socket?
What am I missing in my understanding of how UDP works?
Terry
"recvFrom()" call and other thread sends a UDP packet to some address, that
if the machine on the other end isn't up, that the "recvFrom()" call should
just continue blocking. Right?
What I'm seeing is that when I send a packet to a particular address that is
not responding, my "recvFrom()" call throws an exception. I get "An
existing connection was forcibly closed by the remote host". It shouldn't
do that, right? UDP is connectionless, so if the machine on the other end
isn't running (well, I assume it's not running) it should just continue
blocking right?
Here's the basics of the code. I create the socket.
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
_socket.Bind(new IPEndPoint(IPAddress.Any, 1400) );
Then I spawn two threads, one for reading, one for sending:
_readThread = new Thread(new ThreadStart(read) );
_readThread.Start();
_sendThread = new Thread(new ThreadStart(send) );
_sendThread.Start();
The read thread just blocks on a "recvFrom()" until it gets data (or in this
case throws the above exception). The sending thread has a list of IPs it
needs to send requests to. It may or may not get a response to the request.
Why would I be getting a "connection closed" exception on a UDP socket?
What am I missing in my understanding of how UDP works?
Terry