예제 #1
0
        public IPv4EndPoint(IPEndPoint endPoint)
        {
            if (endPoint.AddressFamily != AddressFamily.InterNetwork)
            {
                throw new ArgumentException("Incompatible address family.", nameof(endPoint));
            }

            Address = new IPv4Address(endPoint.Address);
            Port    = new Port(endPoint.Port);
        }
예제 #2
0
        public static IPAddress?TryParseV4(ReadOnlySpan <char> text)
        {
            Span <byte> addressBytes = stackalloc byte[IPv4Address.ByteCount];

            if (IPv4Address.TryParseInto(text, addressBytes))
            {
                return(new IPAddress(addressBytes));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
 public IPv4EndPoint(IPv4Address address, Port port)
 {
     Address = address;
     Port    = port;
 }