示例#1
0
        public static int GetRemotePort(ISocket socket)
        {
            if (socket.GetSocket().ProtocolType == ProtocolType.Udp)
            {
                throw new ConstraintException("Cannot get remote IP Address of a UDP socket directly. It is returned from the ReceiveMessage as the second item in the Tuple<>");
            }
            var socketEndPoint = (IPEndPoint)socket.GetRemoteEndPoint();

            return(socketEndPoint.Port);
        }
示例#2
0
        public static IPAddress GetRemoteIpAddress(ISocket socket)
        {
            if (socket.GetSocket().ProtocolType == ProtocolType.Udp)
            {
                throw new InvalidOperationException("Cannot get remote IP Address of a UDP socket directly. It is returned from the ReceiveMessage as the second item in the Tuple<>");
            }

            var socketEndPoint = (IPEndPoint)socket.GetRemoteEndPoint();

            return(socketEndPoint.Address);
        }
示例#3
0
 public static int GetRemotePort(ISocket socket)
 {
     if (socket.GetSocket().ProtocolType == ProtocolType.Udp) throw new ConstraintException("Cannot get remote IP Address of a UDP socket directly. It is returned from the ReceiveMessage as the second item in the Tuple<>");
     var socketEndPoint = (IPEndPoint)socket.GetRemoteEndPoint();
     return socketEndPoint.Port;
 }