java.net.ServerSocket.checkListen()方法的使用及代码示例

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

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

ServerSocket.checkListen介绍

暂无

代码示例

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

/**
 * Constructs a new {@code ServerSocket} instance bound to the given {@code localAddress}
 * and {@code port}. The backlog is set to {@code backlog}.
 * If {@code localAddress == null}, the ANY address is used.
 * If {@code port == 0}, a port will be assigned by the OS.
 *
 * @throws IOException if an error occurs while creating the socket.
 */
public ServerSocket(int port, int backlog, InetAddress localAddress) throws IOException {
  checkListen(port);
  this.impl = factory != null ? factory.createSocketImpl()
      : new PlainServerSocketImpl();
  InetAddress addr = (localAddress == null) ? Inet4Address.ANY : localAddress;
  synchronized (this) {
    impl.create(true);
    try {
      impl.bind(addr, port);
      isBound = true;
      impl.listen(backlog > 0 ? backlog : DEFAULT_BACKLOG);
    } catch (IOException e) {
      close();
      throw e;
    }
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * Constructs a new {@code ServerSocket} instance bound to the given {@code localAddress}
 * and {@code port}. The backlog is set to {@code backlog}.
 * If {@code localAddress == null}, the ANY address is used.
 * If {@code port == 0}, a port will be assigned by the OS.
 *
 * @throws IOException if an error occurs while creating the socket.
 */
public ServerSocket(int port, int backlog, InetAddress localAddress) throws IOException {
  checkListen(port);
  this.impl = factory != null ? factory.createSocketImpl()
      : new PlainServerSocketImpl();
  InetAddress addr = (localAddress == null) ? Inet4Address.ANY : localAddress;
  synchronized (this) {
    impl.create(true);
    try {
      impl.bind(addr, port);
      isBound = true;
      impl.listen(backlog > 0 ? backlog : DEFAULT_BACKLOG);
    } catch (IOException e) {
      close();
      throw e;
    }
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Constructs a new {@code ServerSocket} instance bound to the given {@code localAddress}
 * and {@code port}. The backlog is set to {@code backlog}.
 * If {@code localAddress == null}, the ANY address is used.
 * If {@code port == 0}, a port will be assigned by the OS.
 *
 * @throws IOException if an error occurs while creating the socket.
 */
public ServerSocket(int port, int backlog, InetAddress localAddress) throws IOException {
  checkListen(port);
  this.impl = factory != null ? factory.createSocketImpl()
      : new PlainServerSocketImpl();
  InetAddress addr = (localAddress == null) ? Inet4Address.ANY : localAddress;
  synchronized (this) {
    impl.create(true);
    try {
      impl.bind(addr, port);
      isBound = true;
      impl.listen(backlog > 0 ? backlog : DEFAULT_BACKLOG);
    } catch (IOException e) {
      close();
      throw e;
    }
  }
}

代码示例来源:origin: ibinti/bugvm

/**
 * Constructs a new {@code ServerSocket} instance bound to the given {@code localAddress}
 * and {@code port}. The backlog is set to {@code backlog}.
 * If {@code localAddress == null}, the ANY address is used.
 * If {@code port == 0}, a port will be assigned by the OS.
 *
 * @throws IOException if an error occurs while creating the socket.
 */
public ServerSocket(int port, int backlog, InetAddress localAddress) throws IOException {
  checkListen(port);
  this.impl = factory != null ? factory.createSocketImpl()
      : new PlainServerSocketImpl();
  InetAddress addr = (localAddress == null) ? Inet4Address.ANY : localAddress;
  synchronized (this) {
    impl.create(true);
    try {
      impl.bind(addr, port);
      isBound = true;
      impl.listen(backlog > 0 ? backlog : DEFAULT_BACKLOG);
    } catch (IOException e) {
      close();
      throw e;
    }
  }
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Constructs a new {@code ServerSocket} instance bound to the given {@code localAddress}
 * and {@code port}. The backlog is set to {@code backlog}.
 * If {@code localAddress == null}, the ANY address is used.
 * If {@code port == 0}, a port will be assigned by the OS.
 *
 * @throws IOException if an error occurs while creating the socket.
 */
public ServerSocket(int port, int backlog, InetAddress localAddress) throws IOException {
  checkListen(port);
  this.impl = factory != null ? factory.createSocketImpl()
      : new PlainServerSocketImpl();
  InetAddress addr = (localAddress == null) ? Inet4Address.ANY : localAddress;
  synchronized (this) {
    impl.create(true);
    try {
      impl.bind(addr, port);
      isBound = true;
      impl.listen(backlog > 0 ? backlog : DEFAULT_BACKLOG);
    } catch (IOException e) {
      close();
      throw e;
    }
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Constructs a new {@code ServerSocket} instance bound to the given {@code localAddress}
 * and {@code port}. The backlog is set to {@code backlog}.
 * If {@code localAddress == null}, the ANY address is used.
 * If {@code port == 0}, a port will be assigned by the OS.
 *
 * @throws IOException if an error occurs while creating the socket.
 */
public ServerSocket(int port, int backlog, InetAddress localAddress) throws IOException {
  checkListen(port);
  this.impl = factory != null ? factory.createSocketImpl()
      : new PlainServerSocketImpl();
  InetAddress addr = (localAddress == null) ? Inet4Address.ANY : localAddress;
  synchronized (this) {
    impl.create(true);
    try {
      impl.bind(addr, port);
      isBound = true;
      impl.listen(backlog > 0 ? backlog : DEFAULT_BACKLOG);
    } catch (IOException e) {
      close();
      throw e;
    }
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Constructs a new {@code ServerSocket} instance bound to the given {@code localAddress}
 * and {@code port}. The backlog is set to {@code backlog}.
 * If {@code localAddress == null}, the ANY address is used.
 * If {@code port == 0}, a port will be assigned by the OS.
 *
 * @throws IOException if an error occurs while creating the socket.
 */
public ServerSocket(int port, int backlog, InetAddress localAddress) throws IOException {
  checkListen(port);
  this.impl = factory != null ? factory.createSocketImpl()
      : new PlainServerSocketImpl();
  InetAddress addr = (localAddress == null) ? Inet4Address.ANY : localAddress;
  synchronized (this) {
    impl.create(true);
    try {
      impl.bind(addr, port);
      isBound = true;
      impl.listen(backlog > 0 ? backlog : DEFAULT_BACKLOG);
    } catch (IOException e) {
      close();
      throw e;
    }
  }
}

相关文章