Ejemplo n.º 1
0
        public static int BindToAnonymousPort([NotNull] this Socket socket, [NotNull] IPAddress address)
        {
            socket.ArgumentNotNull().Bind(new IPEndPoint(address.ArgumentNotNull(), 0));

            return(((IPEndPoint)socket.LocalEndPoint).Port);
        }