java.nio.channels.SocketChannel.bind()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中java.nio.channels.SocketChannel.bind()方法的一些代码示例,展示了SocketChannel.bind()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketChannel.bind()方法的具体详情如下:
包路径:java.nio.channels.SocketChannel
类名称:SocketChannel
方法名:bind

SocketChannel.bind介绍

暂无

代码示例

代码示例来源:origin: netty/netty

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: redisson/redisson

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: wildfly/wildfly

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: apache/nifi

public SSLSocketChannel(final SSLContext sslContext, final String hostname, final int port, final InetAddress localAddress, final boolean client) throws IOException {
  this.socketAddress = new InetSocketAddress(hostname, port);
  this.channel = SocketChannel.open();
  if (localAddress != null) {
    final SocketAddress localSocketAddress = new InetSocketAddress(localAddress, 0);
    this.channel.bind(localSocketAddress);
  }
  this.hostname = hostname;
  this.port = port;
  this.engine = sslContext.createSSLEngine();
  this.engine.setUseClientMode(client);
  engine.setNeedClientAuth(true);
  streamInManager = new BufferStateManager(ByteBuffer.allocate(engine.getSession().getPacketBufferSize()));
  streamOutManager = new BufferStateManager(ByteBuffer.allocate(engine.getSession().getPacketBufferSize()));
  appDataManager = new BufferStateManager(ByteBuffer.allocate(engine.getSession().getApplicationBufferSize()));
}

代码示例来源:origin: wildfly/wildfly

protected void connect(Address dest, boolean send_local_addr) throws Exception {
  SocketAddress destAddr=new InetSocketAddress(((IpAddress)dest).getIpAddress(), ((IpAddress)dest).getPort());
  try {
    if(!server.deferClientBinding())
      this.channel.bind(new InetSocketAddress(server.clientBindAddress(), server.clientBindPort()));
    this.key=server.register(channel, SelectionKey.OP_CONNECT | SelectionKey.OP_READ, this);
    if(Util.connect(channel, destAddr) && channel.finishConnect()) {
      clearSelectionKey(SelectionKey.OP_CONNECT);
      this.connected=channel.isConnected();
    }
    if(this.channel.getLocalAddress() != null && this.channel.getLocalAddress().equals(destAddr))
      throw new IllegalStateException("socket's bind and connect address are the same: " + destAddr);
    if(send_local_addr)
      sendLocalAddress(server.localAddress());
  }
  catch(Exception t) {
    close();
    throw t;
  }
}

代码示例来源:origin: io.netty/netty-common

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: stackoverflow.com

socket.bind(new InetSocketAddress(address, 8080));

代码示例来源:origin: apache/activemq-artemis

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: jitsi/ice4j

/**
 * {@inheritDoc}
 *
 * Forwards to {@link #delegate} and returns {@code this}.
 */
@Override
public SocketChannel bind(SocketAddress local)
  throws IOException
{
  delegate.bind(local);
  return this;
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: io.bitsensor/proto

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: com.couchbase.client/core-io

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: KostyaSha/yet-another-docker-plugin

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: apache/activemq-artemis

@Override
  public Void run() throws IOException {
    socketChannel.bind(address);
    return null;
  }
});

代码示例来源:origin: undera/jmeter-plugins

@Override
public SocketChannel bind(SocketAddress socketAddress) throws IOException {
  return socketChannel.bind(socketAddress);
}

代码示例来源:origin: cojen/Tupl

private void prepareChannel(SocketChannel channel, SocketAddress addr) throws IOException {
  if (mBindAddress != null) {
    channel.bind(mBindAddress);
  }
  channel.configureBlocking(false);
  channel.register(mSelector, SelectionKey.OP_CONNECT);
  channel.connect(addr);
}

代码示例来源:origin: org.mobicents.protocols.sctp/sctp-impl

private void doInitiateConnectionTcp() throws IOException {
  // Create a non-blocking socket channel
  this.socketChannelTcp = SocketChannel.open();
  this.socketChannelTcp.configureBlocking(false);
  // bind to host address:port
  this.socketChannelTcp.bind(new InetSocketAddress(this.hostAddress, this.hostPort));
  // Kick off connection establishment
  this.socketChannelTcp.connect(new InetSocketAddress(this.peerAddress, this.peerPort));
}

代码示例来源:origin: com.aliyun.openservices/ons-client

private void doBind0(SocketAddress localAddress) throws Exception {
  if (PlatformDependent.javaVersion() >= 7) {
    javaChannel().bind(localAddress);
  } else {
    javaChannel().socket().bind(localAddress);
  }
}

相关文章