Exemple #1
0
        /**
         * Compares this object against the specified object. The result is true if
         * and only if the argument is not null and it represents the same address
         * as this object.
         * <p/>
         * Two instances of InetSocketAddress represent the same address if both the
         * InetAddresses (or hostnames if it is unresolved) and port numbers are
         * equal.
         * <p/>
         * If both addresses are unresolved, then the hostname & the port number are
         * compared.
         * @param obj the object to compare against.
         * @return true if the objects are the same; false otherwise.
         */
        public override bool Equals(Object obj)
        {
            if (!(obj is StunAddress))
            {
                return(false);
            }

            StunAddress target = (StunAddress)obj;

            if (target.socketAddress == null &&
                socketAddress == null)
            {
                return(true);
            }

            return(socketAddress.Equals(target.GetSocketAddress()));
        }
 /**
  * Sends message through this access point's socket.
  * @param message the bytes to send.
  * @param address message destination.
  * @throws IOException if an exception occurs while sending the message.
  */
 public virtual void SendMessage(byte[] message, StunAddress address)
 {
     IPEndPoint ipe = new IPEndPoint(address.GetSocketAddress().GetAddress(),address.GetSocketAddress().GetPort());
     sock.Send(message, message.Length, ipe);
 }
Exemple #3
0
        /**
         * Sends message through this access point's socket.
         * @param message the bytes to send.
         * @param address message destination.
         * @throws IOException if an exception occurs while sending the message.
         */
        public virtual void SendMessage(byte[] message, StunAddress address)
        {
            IPEndPoint ipe = new IPEndPoint(address.GetSocketAddress().GetAddress(), address.GetSocketAddress().GetPort());

            sock.Send(message, message.Length, ipe);
        }