List of usage examples for java.net Socket isClosed
public boolean isClosed()
From source file:neohope.mule.hl7v2.socket.AbstractTcpSocketFactory.java
public boolean validateObject(Object key, Object object) { Socket socket = (Socket) object; return !socket.isClosed(); }
From source file:org.workin.fastdfs.factory.DefaultPoolableTrackerServerFactory.java
@Override public void activateObject(TrackerServer trackerServer) throws Exception { Socket socket = trackerServer.getSocket(); if (!socket.isConnected() || socket.isClosed()) { /* ?TrackerServer */ socket.setSoTimeout(ClientGlobal.g_network_timeout); socket.connect(trackerServer.getInetSocketAddress(), ClientGlobal.g_connect_timeout); }//from w w w . java 2 s . c om }
From source file:com.flipkart.phantom.thrift.impl.proxy.SocketObjectFactory.java
/** * Interface method implementation. Checks if the socket is open and then attempts to set Thrift specific socket properties. * An error in any of these operations will invalidate the specified Socket. * @see org.apache.commons.pool.PoolableObjectFactory#validateObject(Object) *///from www. ja v a2 s.co m public boolean validateObject(Socket socket) { if (socket.isClosed()) { return false; } try { socket.setSoLinger(false, 0); socket.setTcpNoDelay(true); return true; } catch (Exception e) { LOGGER.info("Socket is not valid for server : {} at port : {}", this.getThriftProxy().getThriftServer(), this.getThriftProxy().getThriftPort()); return false; } }
From source file:org.workin.fastdfs.factory.DefaultPoolableTrackerServerFactory.java
@Override public boolean validateObject(TrackerServer trackerServer) { try {/*ww w. j a v a 2 s .c o m*/ Socket socket = trackerServer.getSocket(); if (!socket.isConnected() || socket.isClosed()) return false; } catch (IOException e) { return false; } return true; }
From source file:com.mirth.connect.connectors.file.filesystems.HaltableFTPClient.java
@Override protected Socket _openDataConnection_(String command, String arg) throws IOException { /*// w w w .j av a 2 s .c om * MIRTH-3041, MIRTH-3062 It's possible for the FTP data sockets to hang. We don't have * control over this because different servers may hang for different reasons. For instance * the FTP dispatcher can block on a socket write if the socket buffer of the server it is * connecting to is full. The FTP Receiver and Dispatcher can block on a socket read if the * server they are connecting to is hung. In case this happens, we store references to each * new socket so it can be closed if needed. */ Socket socket = super._openDataConnection_(command, arg); synchronized (openSockets) { for (Iterator<Socket> iterator = openSockets.iterator(); iterator.hasNext();) { Socket openSocket = iterator.next(); if (openSocket != null && openSocket.isClosed()) { iterator.remove(); } } if (socket != null) { openSockets.add(socket); } } return socket; }
From source file:voldemort.store.socket.SocketPoolableObjectFactory.java
public boolean validateObject(Object key, Object value) { SocketAndStreams sands = (SocketAndStreams) value; Socket s = sands.getSocket(); boolean isValid = !s.isClosed() && s.isBound() && s.isConnected(); if (!isValid && logger.isDebugEnabled()) logger.debug("Socket connection " + sands + " is no longer valid, closing."); return isValid; }
From source file:org.jmxtrans.embedded.util.pool.SocketOutputStreamPoolFactory.java
/** * Defensive approach: we test all the "<code>Socket.isXXX()</code>" flags. *//*from www .ja v a 2 s . c om*/ @Override public boolean validateObject(HostAndPort hostAndPort, PooledObject<SocketOutputStream> socketOutputStreamRef) { Socket socket = socketOutputStreamRef.getObject().getSocket(); return socket.isConnected() && socket.isBound() && !socket.isClosed() && !socket.isInputShutdown() && !socket.isOutputShutdown(); }
From source file:org.apache.jmeter.visualizers.backend.graphite.SocketOutputStreamPoolFactory.java
/** *///from w w w.j a v a 2s.c om @Override public boolean validateObject(SocketConnectionInfos hostAndPort, PooledObject<SocketOutputStream> socketOutputStream) { Socket socket = socketOutputStream.getObject().getSocket(); return socket.isConnected() && socket.isBound() && !socket.isClosed() && !socket.isInputShutdown() && !socket.isOutputShutdown(); }
From source file:org.jmxtrans.embedded.util.pool.SocketWriterPoolFactory.java
/** * Defensive approach: we test all the "<code>Socket.isXXX()</code>" flags. *///from w w w. j a v a 2 s . c o m @Override public boolean validateObject(HostAndPort hostAndPort, PooledObject<SocketWriter> socketWriterRef) { Socket socket = socketWriterRef.getObject().getSocket(); return socket.isConnected() && socket.isBound() && !socket.isClosed() && !socket.isInputShutdown() && !socket.isOutputShutdown(); }
From source file:com.predic8.membrane.core.transport.http.HttpEndpointListener.java
/** * Closes all connections or those that are <i>currently</i> idle. * @param onlyIdle whether to close only idle connections * @return true, if there are no more open connections *///w ww . java2 s .com public boolean closeConnections(boolean onlyIdle) throws IOException { if (!closed) throw new IllegalStateException("please call closePort() fist."); for (Socket s : (onlyIdle ? idleSockets : openSockets).keySet()) if (!s.isClosed()) s.close(); return openSockets.isEmpty(); }