Search in sources :

Example 6 with UnsupportedAddressTypeException

use of java.nio.channels.UnsupportedAddressTypeException in project j2objc by google.

the class DatagramChannelImpl method bind.

/** @hide Until ready for a public API change */
@Override
public synchronized DatagramChannel bind(SocketAddress local) throws IOException {
    checkOpen();
    if (isBound) {
        throw new AlreadyBoundException();
    }
    if (local == null) {
        local = new InetSocketAddress(Inet4Address.ANY, 0);
    } else if (!(local instanceof InetSocketAddress)) {
        throw new UnsupportedAddressTypeException();
    }
    InetSocketAddress localAddress = (InetSocketAddress) local;
    NetworkBridge.bind(fd, localAddress.getAddress(), localAddress.getPort());
    onBind(true);
    return this;
}
Also used : UnsupportedAddressTypeException(java.nio.channels.UnsupportedAddressTypeException) AlreadyBoundException(java.nio.channels.AlreadyBoundException) InetSocketAddress(java.net.InetSocketAddress)

Example 7 with UnsupportedAddressTypeException

use of java.nio.channels.UnsupportedAddressTypeException in project netty by netty.

the class AbstractAddressResolver method resolve.

@Override
public final Future<T> resolve(SocketAddress address) {
    if (!isSupported(checkNotNull(address, "address"))) {
        // Address type not supported by the resolver
        return executor().newFailedFuture(new UnsupportedAddressTypeException());
    }
    if (isResolved(address)) {
        // Resolved already; no need to perform a lookup
        @SuppressWarnings("unchecked") final T cast = (T) address;
        return executor.newSucceededFuture(cast);
    }
    try {
        @SuppressWarnings("unchecked") final T cast = (T) address;
        final Promise<T> promise = executor().newPromise();
        doResolve(cast, promise);
        return promise;
    } catch (Exception e) {
        return executor().newFailedFuture(e);
    }
}
Also used : UnsupportedAddressTypeException(java.nio.channels.UnsupportedAddressTypeException) UnsupportedAddressTypeException(java.nio.channels.UnsupportedAddressTypeException)

Example 8 with UnsupportedAddressTypeException

use of java.nio.channels.UnsupportedAddressTypeException in project netty by netty.

the class AbstractAddressResolver method resolveAll.

@Override
public final Future<List<T>> resolveAll(SocketAddress address, Promise<List<T>> promise) {
    checkNotNull(address, "address");
    checkNotNull(promise, "promise");
    if (!isSupported(address)) {
        // Address type not supported by the resolver
        return promise.setFailure(new UnsupportedAddressTypeException());
    }
    if (isResolved(address)) {
        // Resolved already; no need to perform a lookup
        @SuppressWarnings("unchecked") final T cast = (T) address;
        return promise.setSuccess(Collections.singletonList(cast));
    }
    try {
        @SuppressWarnings("unchecked") final T cast = (T) address;
        doResolveAll(cast, promise);
        return promise;
    } catch (Exception e) {
        return promise.setFailure(e);
    }
}
Also used : UnsupportedAddressTypeException(java.nio.channels.UnsupportedAddressTypeException) UnsupportedAddressTypeException(java.nio.channels.UnsupportedAddressTypeException)

Example 9 with UnsupportedAddressTypeException

use of java.nio.channels.UnsupportedAddressTypeException in project netty by netty.

the class AbstractAddressResolver method resolve.

@Override
public final Future<T> resolve(SocketAddress address, Promise<T> promise) {
    checkNotNull(address, "address");
    checkNotNull(promise, "promise");
    if (!isSupported(address)) {
        // Address type not supported by the resolver
        return promise.setFailure(new UnsupportedAddressTypeException());
    }
    if (isResolved(address)) {
        // Resolved already; no need to perform a lookup
        @SuppressWarnings("unchecked") final T cast = (T) address;
        return promise.setSuccess(cast);
    }
    try {
        @SuppressWarnings("unchecked") final T cast = (T) address;
        doResolve(cast, promise);
        return promise;
    } catch (Exception e) {
        return promise.setFailure(e);
    }
}
Also used : UnsupportedAddressTypeException(java.nio.channels.UnsupportedAddressTypeException) UnsupportedAddressTypeException(java.nio.channels.UnsupportedAddressTypeException)

Example 10 with UnsupportedAddressTypeException

use of java.nio.channels.UnsupportedAddressTypeException in project robovm by robovm.

the class UnsupportedAddressTypeExceptionTest method test_Constructor.

/**
     * @tests {@link java.nio.channels.UnsupportedAddressTypeException#UnsupportedAddressTypeException()}
     */
public void test_Constructor() {
    UnsupportedAddressTypeException e = new UnsupportedAddressTypeException();
    assertNull(e.getMessage());
    assertNull(e.getLocalizedMessage());
    assertNull(e.getCause());
}
Also used : UnsupportedAddressTypeException(java.nio.channels.UnsupportedAddressTypeException)

Aggregations

UnsupportedAddressTypeException (java.nio.channels.UnsupportedAddressTypeException)12 InetSocketAddress (java.net.InetSocketAddress)6 SocketAddress (java.net.SocketAddress)4 AlreadyBoundException (java.nio.channels.AlreadyBoundException)3 SctpChannel (com.sun.nio.sctp.SctpChannel)2 AlreadyConnectedException (java.nio.channels.AlreadyConnectedException)2 ClosedChannelException (java.nio.channels.ClosedChannelException)2 UnresolvedAddressException (java.nio.channels.UnresolvedAddressException)2 IllegalUnbindException (com.sun.nio.sctp.IllegalUnbindException)1 SctpServerChannel (com.sun.nio.sctp.SctpServerChannel)1 IOException (java.io.IOException)1 ConnectionPendingException (java.nio.channels.ConnectionPendingException)1 NoConnectionPendingException (java.nio.channels.NoConnectionPendingException)1 ServerSocketChannel (java.nio.channels.ServerSocketChannel)1 SocketChannel (java.nio.channels.SocketChannel)1 List (java.util.List)1