I'm trying to make a simple UDP server by using one UdpClient it works ok with the first connection but if another IP sends something to the same port that is listening is ignored because, as far I know, the socket is connected to another remote IP
MyUdpClient.Connect(RemoteIpEndPoint)
MyUdpClient.Send(Encoding.ASCII.GetBytes(ACK), ACK.Length)
So, after send the ACK I add a line to disconnect from the remote client in order to keep listening
MyUdpClient.Client.Disconnect(True)
But I get error 10057. "A request to send or receive data was disallowed because the socket is not connected...."
Wich is strange because the remote client receives all the data OK, I don't understand what is happening, What is trying to send?
There's any way to know when I can disconnect from the current remote client?
What I need to do is to answer an ACK to every packet and send random data to the last remote IP that send something to the server.
I have more code but is a bit long, if you need it please let me know.
UDP is a connectionless protocol, in contrast to TCP. Therefor you cannot disconnect a UDP client, so the error is correct (though somewhat misleading).
As to why the second connection fails, we need to see your server code. Perhaps you are accidently closing the server UDP socket too?