Java Code Examples for io.netty.util.internal.SocketUtils#bind()

The following examples show how to use io.netty.util.internal.SocketUtils#bind() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OioSocketChannel.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
@Override
protected void doConnect(SocketAddress remoteAddress,
        SocketAddress localAddress) throws Exception {
    if (localAddress != null) {
        SocketUtils.bind(socket, localAddress);
    }

    boolean success = false;
    try {
        SocketUtils.connect(socket, remoteAddress, config().getConnectTimeoutMillis());
        activate(socket.getInputStream(), socket.getOutputStream());
        success = true;
    } catch (SocketTimeoutException e) {
        ConnectTimeoutException cause = new ConnectTimeoutException("connection timed out: " + remoteAddress);
        cause.setStackTrace(e.getStackTrace());
        throw cause;
    } finally {
        if (!success) {
            doClose();
        }
    }
}
 
Example 2
Source File: NioDatagramChannel.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
private void doBind0(SocketAddress localAddress) throws Exception {
    if (PlatformDependent.javaVersion() >= 7) {
        SocketUtils.bind(javaChannel(), localAddress);
    } else {
        javaChannel().socket().bind(localAddress);
    }
}
 
Example 3
Source File: NioSocketChannel.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
private void doBind0(SocketAddress localAddress) throws Exception {
    if (PlatformDependent.javaVersion() >= 7) {
        SocketUtils.bind(javaChannel(), localAddress);
    } else {
        SocketUtils.bind(javaChannel().socket(), localAddress);
    }
}
 
Example 4
Source File: UkcpClientUdpChannel.java    From kcp-netty with MIT License 5 votes vote down vote up
private void doBind0(SocketAddress localAddress) throws Exception {
    if (PlatformDependent.javaVersion() >= 7) {
        SocketUtils.bind(javaChannel(), localAddress);
    } else {
        javaChannel().socket().bind(localAddress);
    }
}
 
Example 5
Source File: UkcpServerChannel.java    From kcp-netty with MIT License 5 votes vote down vote up
private void doBind0(SocketAddress localAddress) throws Exception {
    if (PlatformDependent.javaVersion() >= 7) {
        SocketUtils.bind(javaChannel(), localAddress);
    } else {
        javaChannel().socket().bind(localAddress);
    }
}
 
Example 6
Source File: OioSocketChannel.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
protected void doBind(SocketAddress localAddress) throws Exception {
    SocketUtils.bind(socket, localAddress);
}