/*
 * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
 * which is available at https://www.apache.org/licenses/LICENSE-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
 */

package io.vertx.core.net;

import io.vertx.codegen.annotations.CacheReturn;
import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.net.impl.SocketAddressImpl;

import java.net.InetSocketAddress;

The address of a socket, an inet socket address or a domain socket address.

Use inetSocketAddress(int, String) to create an inet socket address and domainSocketAddress(String) to create a domain socket address
Author:Tim Fox
/** * The address of a socket, an inet socket address or a domain socket address. * <p/> * Use {@link #inetSocketAddress(int, String)} to create an inet socket address and {@link #domainSocketAddress(String)} * to create a domain socket address * * @author <a href="http://tfox.org">Tim Fox</a> */
@VertxGen public interface SocketAddress {
Create a inet socket address, host must be non null and port must be between 0 and 65536.
The host string can be an host name or an host address.
No name resolution will be attempted.
Params:
  • port – the port
  • host – the host
Returns:the created socket address
/** * Create a inet socket address, {@code host} must be non {@code null} and {@code port} must be between {@code 0} * and {@code 65536}. * <br/> * The {@code host} string can be an host name or an host address. * <br/> * No name resolution will be attempted. * * @param port the port * @param host the host * @return the created socket address */
static SocketAddress inetSocketAddress(int port, String host) { return new SocketAddressImpl(port, host); }
Create a domain socket address from a path.
Params:
  • path – the address path
Returns:the created socket address
/** * Create a domain socket address from a {@code path}. * * @param path the address path * @return the created socket address */
static SocketAddress domainSocketAddress(String path) { return new SocketAddressImpl(path); }
Create a inet socket address from a Java InetSocketAddress.
No name resolution will be attempted.
Params:
  • address – the address
Returns:the created socket address
/** * Create a inet socket address from a Java {@link InetSocketAddress}. * <br/> * No name resolution will be attempted. * * @param address the address * @return the created socket address */
@GenIgnore(GenIgnore.PERMITTED_TYPE) static SocketAddress inetSocketAddress(InetSocketAddress address) { return new SocketAddressImpl(address); }
Returns the host name when available or the IP address in string representation.
Domain socket address returns null.
Returns:the host address
/** * Returns the host name when available or the IP address in string representation. * <br/> * Domain socket address returns {@code null}. * * @return the host address */
@CacheReturn String host();
Returns the host name when available or null
Domain socket address returns null.
Returns:the host name
/** * Returns the host name when available or {@code null} * <br/> * Domain socket address returns {@code null}. * * @return the host name */
@CacheReturn String hostName();
Returns the host IP address when available or null as a String.
Domain socket address returns null.
Returns:the host address
/** * Returns the host IP address when available or {@code null} as a String. * <br/> * Domain socket address returns {@code null}. * * @return the host address */
@CacheReturn String hostAddress();
Returns:the address port or -1 for a domain socket
/** * @return the address port or {@code -1} for a domain socket */
@CacheReturn int port();
Returns:the domain socket path or null for a inet socket address.
/** * @return the domain socket path or {@code null} for a inet socket address. */
@CacheReturn String path();
Returns:true for an inet socket address
/** * @return {@code true} for an inet socket address */
@CacheReturn boolean isInetSocket();
Returns:true for an domain socket address
/** * @return {@code true} for an domain socket address */
@CacheReturn boolean isDomainSocket(); }