For example, if you have:
var endPoint = new IPEndPoint(IPAddress.IPv6Any, 800); using (var socket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) { socket.Bind(endPoint); socket.Listen(int.MaxValue); socket.AcceptAsync(new SocketAsyncEventArgs().Completed += ...); }
you will start listening for all incoming connections from all IPv6 addresses on port 800. Now, if you create another socket with the exact IP address on the same port, the new socket will take priority and will start listening on this exact IP address on port 800. This is useful for a smaller set of scenarios (i.e., for a transient connection where you read / write to the exact IP address using a secure channel).
source share