If I do something like this:
byte[] buffer = new byte[1024];
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint remote = new IPEndPoint(IPAddress.Parse("12.34.56.78"), 1337);
sock.ReceiveFrom(buffer, ref remote);
Will the ReceiveFrom method receive packets only from the transmitted endpoint? The documentation states the following:
In connectionless protocols, ReceiveFrom will read the first nested datagram received in the LAN buffer.
Does this mean that the passed EndPoint is used only to store the endpoint of the host from which the packet came and does not affect the behavior of the ReceiveFrom method at all? If so, why should this be passed as "ref" instead of "out"?
source
share