@Override public boolean isBound() { return sock.isBound(); }
@Override boolean isSocketBound() { return socket.isBound(); }
Socket s = new Socket(); System.out.println("isConnected: " + s.isConnected() + " isBound: " + s.isBound() + " isClosed: " + s.isClosed()); s.connect(new InetSocketAddress("google.com", 80)); System.out.println("isConnected: " + s.isConnected() + " isBound: " + s.isBound() + " isClosed: " + s.isClosed()); s.close(); System.out.println("isConnected: " + s.isConnected() + " isBound: " + s.isBound() + " isClosed: " + s.isClosed());
/** * Returns the local address and port of this socket as a SocketAddress or * null if the socket is unbound. This is useful on multihomed * hosts. */ public SocketAddress getLocalSocketAddress() { if (!isBound()) { return null; } return new InetSocketAddress(getLocalAddress(), getLocalPort()); }
/** * See {@link Socket#isBound()}. Calling this method does not trigger mode detection. */ @Override public boolean isBound() { return getSocketAllowUnknownMode().isBound(); }
/** * Returns the local port this socket is bound to, or -1 if the socket is unbound. */ public int getLocalPort() { if (!isBound()) { return -1; } return impl.getLocalPort(); }
@Signature public Memory isBound(Environment env, Memory... args) { return socket.isBound() ? Memory.TRUE : Memory.FALSE; }
public boolean isConnected() { return socket != null && socket.isBound() && !socket.isClosed() && socket.isConnected() && !socket.isInputShutdown() && !socket.isOutputShutdown(); }
public boolean isValid() { if(isClosed()) return false; Socket s = socketChannel.socket(); boolean isValidSocket = !s.isClosed() && s.isBound() && s.isConnected(); if(!isValidSocket) { return false; } if (isIdleConnectionTimeoutExceeded()) { return false; } return true; }
if (!socket.isBound()) { log.error("Socket is not bound [{}]", address); return false;
@Override public boolean hasExpired(SlotInfo<? extends SocketPoolable> info) throws Exception { Socket socket = info.getPoolable().getSocket(); try { return socket == null || !socket.isConnected() || !socket.isBound() || socket.isClosed() || socket.isInputShutdown() || socket.isOutputShutdown(); } catch (Exception e) { log.warn("Socket {} is expired", socket, e); return true; } } }
socket.setReuseAddress( isReuseAddr() ); if( !socket.isBound() ) { socket.connect( new InetSocketAddress( uri.getHost(), getPort() ), connectTimeout );
@Override public void connect(SocketAddress remoteAddr, int timeout) throws IOException { if (!channel.isBlocking()) { throw new IllegalBlockingModeException(); } if (isConnected()) { throw new AlreadyConnectedException(); } super.connect(remoteAddr, timeout); channel.initLocalAddressAndPort(); if (super.isConnected()) { channel.setConnected(); channel.isBound = super.isBound(); } }
if (isBound()) { throw new BindException("Socket is already bound");
synchronized (connectLock) { try { if (!isBound()) {
boolean isValid = !s.isClosed() && s.isBound() && s.isConnected(); if(!isValid && logger.isDebugEnabled()) logger.debug("Socket connection " + sands + " is no longer valid, closing.");
@Test public void testRepeatedClosedConnections() throws Exception { for(int i = 0; i < 100; i++) { Socket s = new Socket(); s.setTcpNoDelay(true); s.setSoTimeout(1000); s.connect(new InetSocketAddress("localhost", socketPort)); logger.info("Client opened" + i); // Thread.sleep(1); assertTrue(s.isConnected()); assertTrue(s.isBound()); assertTrue(!s.isClosed()); s.close(); logger.info("Client closed" + i); } }
return delegate.isBound();
return delegate.isBound();
return delegate.isBound();