コード例 #1
0
        /**
         * Two instances of InetSocketAddress represent the same address if both the
         * InetAddresses (or hostnames if it is unresolved) and port numbers are
         * equal.
         * <p/>
         * @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 InetSocketAddress))
            {
                return(false);
            }

            InetSocketAddress target = (InetSocketAddress)obj;

            return(this.addr.Equals(target.addr) && this.port.Equals(target.port));
        }
コード例 #2
0
        /**
         * Creates an address instance address from a byte array containing an IP
         * address and a port number.
         * <p>
         * A valid port value is between 0 and 65535.
         * A port number of <code>zero</code> will let the system pick up an
         * ephemeral port in a <code>bind</code> operation.
         * <P>
         * A <code>null</code> address will assign the <i>wildcard</i> address.
         * <p>
         * @param	ipAddress The IP address
         * @param	port      The port number
         * @throws IllegalArgumentException if the port parameter is outside the
         * specified range of valid port values or if ipAddress is not a valid ip
         * address.
         */
        public StunAddress(byte[] ipAddress, int port)
        {
            //socketAddress = new InetSocketAddress(InetAddress.getByAddress(
            //    ipAddress), port);

            //Unknown Host - Let's skip resolution
            socketAddress = new InetSocketAddress((ipAddress[0] & 0xFF) + "."
                                                  + (ipAddress[1] & 0xFF) + "."
                                                  + (ipAddress[2] & 0xFF) + "."
                                                  + (ipAddress[3] & 0xFF) + ".",
                                                  port);
        }
コード例 #3
0
ファイル: StunAddress.cs プロジェクト: hughperkins/osmp-cs
        /**
         * Creates an address instance address from a byte array containing an IP
         * address and a port number.
         * <p>
         * A valid port value is between 0 and 65535.
         * A port number of <code>zero</code> will let the system pick up an
         * ephemeral port in a <code>bind</code> operation.
         * <P>
         * A <code>null</code> address will assign the <i>wildcard</i> address.
         * <p>
         * @param	ipAddress The IP address
         * @param	port      The port number
         * @throws IllegalArgumentException if the port parameter is outside the
         * specified range of valid port values or if ipAddress is not a valid ip
         * address.
         */
        public StunAddress(byte[] ipAddress, int port)
        {
            //socketAddress = new InetSocketAddress(InetAddress.getByAddress(
                //    ipAddress), port);

                //Unknown Host - Let's skip resolution
                socketAddress = new InetSocketAddress((ipAddress[0]&0xFF) + "."
                    +(ipAddress[1]&0xFF) + "."
                    +(ipAddress[2]&0xFF) + "."
                    +(ipAddress[3]&0xFF) + ".",
                    port);
        }
コード例 #4
0
        /**
         * Constructs a raw message with the specified field values. All parameters
         * are cloned before being assigned to class members.
         *
         * @param messageBytes      the message itself.
         * @param remoteAddress     the address where the message came from.
         * @param remotePort        the port where the message came from.
         * @param netApDescriptor   the access point the received the message.s
         *
         * @throws NullPointerException if one or more of the parameters were null.
         */
        public RawMessage(byte[]                   messageBytes,
                          int messageLength,
                          IPAddress remoteAddress,
                          int remotePort,
                          IPAddress localAddress,
                          int localPort,
                          NetAccessPointDescriptor netApDescriptor)
        {
            //... don't do a null check - let it throw an NP exception
            string s = localAddress.ToString();

            this.messageBytes  = new byte[messageBytes.Length];
            this.messageLength = messageLength;
            for (int x = 0; x < messageBytes.Length; x++)
            {
                this.messageBytes[x] = messageBytes[x];
            }

            this.remoteAddress        = new InetSocketAddress(remoteAddress, remotePort);
            this.receivingAccessPoint =
                (NetAccessPointDescriptor)netApDescriptor.Clone();
        }
コード例 #5
0
ファイル: RawMessage.cs プロジェクト: hughperkins/osmp-cs
        /**
         * Constructs a raw message with the specified field values. All parameters
         * are cloned before being assigned to class members.
         *
         * @param messageBytes      the message itself.
         * @param remoteAddress     the address where the message came from.
         * @param remotePort        the port where the message came from.
         * @param netApDescriptor   the access point the received the message.s
         *
         * @throws NullPointerException if one or more of the parameters were null.
         */
        public RawMessage(byte[]                   messageBytes,
			int                      messageLength,
			IPAddress				remoteAddress,
			int						remotePort,
			IPAddress localAddress,
			int localPort,
			NetAccessPointDescriptor netApDescriptor)
        {
            //... don't do a null check - let it throw an NP exception
            string s = localAddress.ToString();

            this.messageBytes  = new byte[messageBytes.Length];
            this.messageLength = messageLength;
            for (int x = 0; x < messageBytes.Length; x++)
            {
                this.messageBytes[x] = messageBytes[x];
            }

            this.remoteAddress = new InetSocketAddress(remoteAddress, remotePort);
            this.receivingAccessPoint    =
                (NetAccessPointDescriptor)netApDescriptor.Clone();
        }
コード例 #6
0
 /**
  * Creates an address instance from a hostname and a port number.
  * <p>
  * An attempt will be made to resolve the hostname into an InetAddress.
  * If that attempt fails, the address will be flagged as <I>unresolved</I>.
  * <p>
  * A valid port value is between 0 and 65535.
  * A port number of <code>zero</code> will let the system pick up an
  * ephemeral port in a <code>bind</code> operation.
  * <P>
  * @param	address the address itself
  * @param	port	the port number
  * @throws IllegalArgumentException if the port parameter is outside the
  * range of valid port values, or if the hostname parmeter is <TT>null</TT>.
  */
 public StunAddress(IPAddress address, int port)
 {
     socketAddress = new InetSocketAddress(address, port);
 }
コード例 #7
0
 /**
  * Creates an address instance address from an IP address and a port number.
  * <p>
  * A valid port value is between 0 and 65535.
  * A port number of <code>zero</code> will let the system pick up an
  * ephemeral port in a <code>bind</code> operation.
  * <P>
  * A <code>null</code> address will assign the <i>wildcard</i> address.
  * <p>
  * @param	hostname	The IP address
  * @param	port	    The port number
  * @throws IllegalArgumentException if the port parameter is outside the
  * specified range of valid port values.
  */
 public StunAddress(String hostname, int port)
 {
     socketAddress = new InetSocketAddress(hostname, port);
 }
コード例 #8
0
 /**
  * Creates an address instance from the localhost amd a port number.
  * <p>
  * Addresses created with this constructor should be used cautiously as
  * they won't be trated as equal to address created from the localhost
  * address even though the represent the same thing. In other words - use
  * this constructor only if you're not going to compare the resulting
  * instance with other addresses.
  *
  * @param	port	the port number
  * @throws IllegalArgumentException if the port parameter is outside the
  * range of valid port values, or if the hostname parmeter is <TT>null</TT>.
  */
 public StunAddress(int port)
 {
     socketAddress = new InetSocketAddress(IPAddress.Any, port);
 }
コード例 #9
0
ファイル: StunAddress.cs プロジェクト: hughperkins/osmp-cs
 /**
  * Creates an address instance from a hostname and a port number.
  * <p>
  * An attempt will be made to resolve the hostname into an InetAddress.
  * If that attempt fails, the address will be flagged as <I>unresolved</I>.
  * <p>
  * A valid port value is between 0 and 65535.
  * A port number of <code>zero</code> will let the system pick up an
  * ephemeral port in a <code>bind</code> operation.
  * <P>
  * @param	address the address itself
  * @param	port	the port number
  * @throws IllegalArgumentException if the port parameter is outside the
  * range of valid port values, or if the hostname parmeter is <TT>null</TT>.
  */
 public StunAddress(IPAddress address, int port)
 {
     socketAddress = new InetSocketAddress(address, port);
 }
コード例 #10
0
ファイル: StunAddress.cs プロジェクト: hughperkins/osmp-cs
 /**
  * Creates an address instance address from an IP address and a port number.
  * <p>
  * A valid port value is between 0 and 65535.
  * A port number of <code>zero</code> will let the system pick up an
  * ephemeral port in a <code>bind</code> operation.
  * <P>
  * A <code>null</code> address will assign the <i>wildcard</i> address.
  * <p>
  * @param	hostname	The IP address
  * @param	port	    The port number
  * @throws IllegalArgumentException if the port parameter is outside the
  * specified range of valid port values.
  */
 public StunAddress(String hostname, int port)
 {
     socketAddress = new InetSocketAddress(hostname, port);
 }
コード例 #11
0
ファイル: StunAddress.cs プロジェクト: hughperkins/osmp-cs
 /**
  * Creates an address instance from the localhost amd a port number.
  * <p>
  * Addresses created with this constructor should be used cautiously as
  * they won't be trated as equal to address created from the localhost
  * address even though the represent the same thing. In other words - use
  * this constructor only if you're not going to compare the resulting
  * instance with other addresses.
  *
  * @param	port	the port number
  * @throws IllegalArgumentException if the port parameter is outside the
      * range of valid port values, or if the hostname parmeter is <TT>null</TT>.
  */
 public StunAddress(int port)
 {
     socketAddress = new InetSocketAddress(IPAddress.Any,port);
 }