/** * 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; } } }
/** * 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; } } }
/** * 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; } } }
/** * 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; } } }
/** * 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; } } }
/** * 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; } } }
/** * 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; } } }