@Override public boolean isActive() { return isOpen() && socket.isBound(); }
@Override public boolean isActive() { return javaChannel().socket().isBound(); }
/** * Returns port on which server is listening or -1 if server failed to bound to a port. * @return port or -1 if server failed to bound to a port */ public int getPort() { return (server != null) && server.isBound() ? server.getLocalPort() : -1; }
@Override public boolean isActive() { return isOpen() && socket.isBound(); }
@Override public boolean isActive() { return javaChannel().socket().isBound(); }
/** * Gets the local socket address of this server socket or {@code null} if * the socket is unbound. This is useful on multihomed hosts. * * @return the local socket address and port this socket is bound to. */ public SocketAddress getLocalSocketAddress() { if (!isBound()) { return null; } return new InetSocketAddress(getInetAddress(), getLocalPort()); }
/** * Gets the local port of this server socket or {@code -1} if the socket is * unbound. * * @return the local port this server is listening on. */ public int getLocalPort() { if (!isBound()) { return -1; } return impl.getLocalPort(); }
@Override public boolean isActive() { return isOpen() && socket.isBound(); }
/** * Gets the local IP address of this server socket or {@code null} if the * socket is unbound. This is useful for multihomed hosts. * * @return the local address of this server socket. */ public InetAddress getInetAddress() { if (!isBound()) { return null; } return impl.getInetAddress(); }
@Override public boolean isActive() { return javaChannel().socket().isBound(); }
@Signature public Memory isBound(Environment env, Memory... args) { return socket.isBound() ? Memory.TRUE : Memory.FALSE; }
public boolean isBound() { return isOpen() && socket.socket().isBound(); }
public boolean isBound() { return isOpen() && socket.isBound(); }
/** * Returns a textual representation of this server socket including the * address, port and the state. The port field is set to {@code 0} if there * is no connection to the server socket. * * @return the textual socket representation. */ @Override public String toString() { StringBuilder result = new StringBuilder(64); result.append("ServerSocket["); if (!isBound()) { return result.append("unbound]").toString(); } return result.append("addr=") .append(getInetAddress().getHostName()).append("/") .append(getInetAddress().getHostAddress()).append( ",port=0,localport=") .append(getLocalPort()).append("]") .toString(); }
/** * @param socket * @param bindAddress * @return real hostName * @throws UnknownHostException */ protected String resolveHostName(ServerSocket socket, InetAddress bindAddress) throws UnknownHostException { String result = null; if (socket.isBound()) { if (socket.getInetAddress().isAnyLocalAddress()) { // make it more human readable and useful, an alternative to 0.0.0.0 result = InetAddressUtil.getLocalHostName(); } else { result = socket.getInetAddress().getCanonicalHostName(); } } else { result = bindAddress.getCanonicalHostName(); } return result; }
return; while (serverSocket.isBound()) { final Socket socket; try {
/** * Waits for an incoming request and blocks until the connection is opened. * This method returns a socket object representing the just opened * connection. * * @return the connection representing socket. * @throws IOException * if an error occurs while accepting a new connection. */ public Socket accept() throws IOException { checkOpen(); if (!isBound()) { throw new SocketException("Socket is not bound"); } Socket aSocket = new Socket(); try { implAccept(aSocket); } catch (IOException e) { aSocket.close(); throw e; } return aSocket; }
log.logMinimal( "Carte socket repository : Starting a retry loop to bind the server socket on port " + port + ". We retry for 5 minutes until the socket clears in your operating system." ); while ( !serverSocket.isBound() && totalWait < 300000 ) { try { totalWait = System.currentTimeMillis() - startTime; if ( !serverSocket.isBound() ) { serverSocket.close(); throw ioException;
if (isBound()) { throw new BindException("Socket is already bound");