C # Sockets: Why does the .LocalEndPoint socket change?

In UDP client, after execution:

socket.SendTo(data, SendIP);

      

Why does the .LocalEndPoint socket change?

+2


a source to share


1 answer


If you've never called socket.Bind, then on the first transmission the UDP stack will automatically assign you a local address.

Quoting from MSDN:



If you are using a connectionless protocol, you do not need to set the default remote host using the Connect method before calling SendTo ..... You also do not need to call the Bind method, because the main service provider will assign the most appropriate LAN address and port number ...

+3


a source







All Articles