public String toString() { Socket tmp_sock=sock; if(tmp_sock == null) return "<null socket>"; InetAddress local=tmp_sock.getLocalAddress(), remote=tmp_sock.getInetAddress(); String local_str=local != null? Util.shortName(local) : "<null>"; String remote_str=remote != null? Util.shortName(remote) : "<null>"; return String.format("%s:%s --> %s:%s (%d secs old) [%s] [recv_buf=%d]", local_str, tmp_sock.getLocalPort(), remote_str, tmp_sock.getPort(), TimeUnit.SECONDS.convert(getTimestamp() - last_access, TimeUnit.NANOSECONDS), status(), receiver != null? receiver.bufferSize() : 0); }
public void run() { Throwable t=null; while(canRun()) { try { int len=in.readInt(); // needed to read messages from TCP_NIO2 server.receive(peer_addr, in, len); updateLastAccessed(); } catch(OutOfMemoryError mem_ex) { t=mem_ex; break; // continue; } catch(IOException io_ex) { t=io_ex; break; } catch(Throwable e) { } } server.notifyConnectionClosed(TcpConnection.this, String.format("%s: %s", getClass().getSimpleName(), t != null? t.toString() : "n/a")); } }
public void close() throws IOException { send_lock.lock(); try { Util.close(out, in, sock); if(receiver != null) { receiver.stop(); receiver=null; } } finally { connected=false; send_lock.unlock(); } } }
public void run() { Throwable t=null; while(canRun()) { try { int len=in.readInt(); // needed to read messages from TCP_NIO2 server.receive(peer_addr, in, len); updateLastAccessed(); } catch(OutOfMemoryError mem_ex) { t=mem_ex; break; // continue; } catch(IOException io_ex) { t=io_ex; break; } catch(Throwable e) { } } server.notifyConnectionClosed(TcpConnection.this, String.format("%s: %s", getClass().getSimpleName(), t != null? t.toString() : "n/a")); } }
public void close() throws IOException { send_lock.lock(); try { Util.close(out, in, sock); if(receiver != null) { receiver.stop(); receiver=null; } } finally { connected=false; send_lock.unlock(); } } }
public boolean canRun() {return isRunning() && isConnected();} public int bufferSize() {return buffer != null? buffer.length : 0;}
public String toString() { Socket tmp_sock=sock; if(tmp_sock == null) return "<null socket>"; InetAddress local=tmp_sock.getLocalAddress(), remote=tmp_sock.getInetAddress(); String local_str=local != null? Util.shortName(local) : "<null>"; String remote_str=remote != null? Util.shortName(remote) : "<null>"; return String.format("%s:%s --> %s:%s (%d secs old) [%s] [recv_buf=%d]", local_str, tmp_sock.getLocalPort(), remote_str, tmp_sock.getPort(), TimeUnit.SECONDS.convert(getTimestamp() - last_access, TimeUnit.NANOSECONDS), status(), receiver != null? receiver.bufferSize() : 0); }
public boolean canRun() {return isRunning() && isConnected();} public int bufferSize() {return buffer != null? buffer.length : 0;}