net.i2p.client.streaming

## Class I2PSocketAddress

- java.lang.Object
- - java.net.SocketAddress
  - - net.i2p.client.streaming.I2PSocketAddress

- All Implemented Interfaces:
    Serializable

      public class I2PSocketAddress
      extends SocketAddress

  A SocketAddress (Destination + port) so we can have SocketChannels. Ports are not widely used in I2P, in most cases the port will be zero. See InetSocketAddress for javadocs.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `I2PSocketAddress(Destination dest, int port)` Does not do a reverse lookup.
    `I2PSocketAddress(String host)` Convenience constructor that parses host:port.
    `I2PSocketAddress(String host, int port)` Does a naming service lookup to resolve the dest.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static I2PSocketAddress` | `createUnresolved(String host, int port)`
    `boolean` | `equals(Object obj)`
    `Destination` | `getAddress()` Does a naming service lookup to resolve the dest if this was created unresolved or if the resolution failed in the constructor.
    `String` | `getHostName()`
    `int` | `getPort()`
    `int` | `hashCode()`
    `boolean` | `isUnresolved()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### I2PSocketAddress

          public I2PSocketAddress(Destination dest,
                                  int port)

      Does not do a reverse lookup. Host will be null.
      Throws:
        `IllegalArgumentException` - for port < 0 or port > 65535

    - #### I2PSocketAddress

          public I2PSocketAddress(String host)

      Convenience constructor that parses host:port. Does a naming service lookup to resolve the dest. May take several seconds for b32.
      Parameters:
        `host` - hostname or b64 dest or b32, may have :port appended
      Throws:
        `IllegalArgumentException` - for port < 0 or port > 65535 or invalid port

    - #### I2PSocketAddress

          public I2PSocketAddress(String host,
                                  int port)

      Does a naming service lookup to resolve the dest. May take several seconds for b32.
      Throws:
        `IllegalArgumentException` - for port < 0 or port > 65535

  - ### Method Detail

    - #### createUnresolved

          public static I2PSocketAddress createUnresolved(String host,
                                                          int port)

      Throws:
        `IllegalArgumentException` - for port < 0 or port > 65535

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### getAddress

          public Destination getAddress()

      Does a naming service lookup to resolve the dest if this was created unresolved or if the resolution failed in the constructor. If unresolved, this may take several seconds for b32.

    - #### getHostName

          public String getHostName()

      Returns:
        the host only if given in the constructor. Does not do a reverse lookup.

    - #### getPort

          public int getPort()

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### isUnresolved

          public boolean isUnresolved()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`