Uses of Class java.net.SocketAddress (Java Platform SE 8 )
Date: 2020-03-26

## Uses of Class
java.net.SocketAddress

- Packages that use SocketAddress
  Package | Description
  --- | ---
  java.net | Provides the classes for implementing networking applications.
  java.nio.channels | Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets; defines selectors, for multiplexed, non-blocking I/O operations.

- - ### Uses of SocketAddress in java.net

    Subclasses of SocketAddress in java.net
    Modifier and Type | Class and Description
    --- | ---
    `class` | `InetSocketAddress` This class implements an IP Socket Address (IP address + port number) It can also be a pair (hostname + port number), in which case an attempt will be made to resolve the hostname.

    Methods in java.net that return SocketAddress
    Modifier and Type | Method and Description
    --- | ---
    `SocketAddress` | Proxy.`address()` Returns the socket address of the proxy, or `null` if its a direct connection.
    `SocketAddress` | DatagramSocket.`getLocalSocketAddress()` Returns the address of the endpoint this socket is bound to.
    `SocketAddress` | ServerSocket.`getLocalSocketAddress()` Returns the address of the endpoint this socket is bound to.
    `SocketAddress` | Socket.`getLocalSocketAddress()` Returns the address of the endpoint this socket is bound to.
    `SocketAddress` | DatagramSocket.`getRemoteSocketAddress()` Returns the address of the endpoint this socket is connected to, or `null` if it is unconnected.
    `SocketAddress` | Socket.`getRemoteSocketAddress()` Returns the address of the endpoint this socket is connected to, or `null` if it is unconnected.
    `SocketAddress` | DatagramPacket.`getSocketAddress()` Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.

    Methods in java.net with parameters of type SocketAddress
    Modifier and Type | Method and Description
    --- | ---
    `void` | DatagramSocket.`bind(SocketAddress addr)` Binds this DatagramSocket to a specific address and port.
    `void` | ServerSocket.`bind(SocketAddress endpoint)` Binds the `ServerSocket` to a specific address (IP address and port number).
    `void` | Socket.`bind(SocketAddress bindpoint)` Binds the socket to a local address.
    `void` | ServerSocket.`bind(SocketAddress endpoint, int backlog)` Binds the `ServerSocket` to a specific address (IP address and port number).
    `void` | DatagramSocket.`connect(SocketAddress addr)` Connects this socket to a remote socket address (IP address + port number).
    `void` | Socket.`connect(SocketAddress endpoint)` Connects this socket to the server.
    `protected abstract void` | SocketImpl.`connect(SocketAddress address, int timeout)` Connects this socket to the specified port number on the specified host.
    `void` | Socket.`connect(SocketAddress endpoint, int timeout)` Connects this socket to the server with a specified timeout value.
    `abstract void` | ProxySelector.`connectFailed(URI uri, SocketAddress sa, IOException ioe)` Called to indicate that a connection could not be established to a proxy/socks server.
    `protected abstract void` | DatagramSocketImpl.`joinGroup(SocketAddress mcastaddr, NetworkInterface netIf)` Join the multicast group.
    `void` | MulticastSocket.`joinGroup(SocketAddress mcastaddr, NetworkInterface netIf)` Joins the specified multicast group at the specified interface.
    `protected abstract void` | DatagramSocketImpl.`leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf)` Leave the multicast group.
    `void` | MulticastSocket.`leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf)` Leave a multicast group on a specified local interface.
    `void` | DatagramPacket.`setSocketAddress(SocketAddress address)` Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.

    Constructors in java.net with parameters of type SocketAddress
    Constructor and Description
    `DatagramPacket(byte[] buf, int offset, int length, SocketAddress address)` Constructs a datagram packet for sending packets of length `length` with offset `ioffset`to the specified port number on the specified host.
    `DatagramPacket(byte[] buf, int length, SocketAddress address)` Constructs a datagram packet for sending packets of length `length` to the specified port number on the specified host.
    `DatagramSocket(SocketAddress bindaddr)` Creates a datagram socket, bound to the specified local socket address.
    `MulticastSocket(SocketAddress bindaddr)` Create a MulticastSocket bound to the specified socket address.
    `Proxy(Proxy.Type type, SocketAddress sa)` Creates an entry representing a PROXY connection.

  - ### Uses of SocketAddress in java.nio.channels

    Methods in java.nio.channels that return SocketAddress
    Modifier and Type | Method and Description
    --- | ---
    `abstract SocketAddress` | DatagramChannel.`getLocalAddress()` Returns the socket address that this channel's socket is bound to.
    `abstract SocketAddress` | ServerSocketChannel.`getLocalAddress()` Returns the socket address that this channel's socket is bound to.
    `abstract SocketAddress` | AsynchronousSocketChannel.`getLocalAddress()` Returns the socket address that this channel's socket is bound to.
    `abstract SocketAddress` | SocketChannel.`getLocalAddress()` Returns the socket address that this channel's socket is bound to.
    `abstract SocketAddress` | AsynchronousServerSocketChannel.`getLocalAddress()` Returns the socket address that this channel's socket is bound to.
    `SocketAddress` | NetworkChannel.`getLocalAddress()` Returns the socket address that this channel's socket is bound to.
    `abstract SocketAddress` | DatagramChannel.`getRemoteAddress()` Returns the remote address to which this channel's socket is connected.
    `abstract SocketAddress` | AsynchronousSocketChannel.`getRemoteAddress()` Returns the remote address to which this channel's socket is connected.
    `abstract SocketAddress` | SocketChannel.`getRemoteAddress()` Returns the remote address to which this channel's socket is connected.
    `abstract SocketAddress` | DatagramChannel.`receive(ByteBuffer dst)` Receives a datagram via this channel.

    Methods in java.nio.channels with parameters of type SocketAddress
    Modifier and Type | Method and Description
    --- | ---
    `abstract DatagramChannel` | DatagramChannel.`bind(SocketAddress local)`
    `ServerSocketChannel` | ServerSocketChannel.`bind(SocketAddress local)` Binds the channel's socket to a local address and configures the socket to listen for connections.
    `abstract AsynchronousSocketChannel` | AsynchronousSocketChannel.`bind(SocketAddress local)`
    `abstract SocketChannel` | SocketChannel.`bind(SocketAddress local)`
    `AsynchronousServerSocketChannel` | AsynchronousServerSocketChannel.`bind(SocketAddress local)` Binds the channel's socket to a local address and configures the socket to listen for connections.
    `NetworkChannel` | NetworkChannel.`bind(SocketAddress local)` Binds the channel's socket to a local address.
    `abstract ServerSocketChannel` | ServerSocketChannel.`bind(SocketAddress local, int backlog)` Binds the channel's socket to a local address and configures the socket to listen for connections.
    `abstract AsynchronousServerSocketChannel` | AsynchronousServerSocketChannel.`bind(SocketAddress local, int backlog)` Binds the channel's socket to a local address and configures the socket to listen for connections.
    `abstract DatagramChannel` | DatagramChannel.`connect(SocketAddress remote)` Connects this channel's socket.
    `abstract Future<Void>` | AsynchronousSocketChannel.`connect(SocketAddress remote)` Connects this channel.
    `abstract boolean` | SocketChannel.`connect(SocketAddress remote)` Connects this channel's socket.
    `abstract <A> void` | AsynchronousSocketChannel.`connect(SocketAddress remote, A attachment, CompletionHandler<Void,? super A> handler)` Connects this channel.
    `static SocketChannel` | SocketChannel.`open(SocketAddress remote)` Opens a socket channel and connects it to a remote address.
    `abstract int` | DatagramChannel.`send(ByteBuffer src, SocketAddress target)` Sends a datagram via this channel.

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.