public void setReceiveTimeout(TcpSocket fan, Duration v) { try { if (v == null) socket.setSoTimeout(0); else socket.setSoTimeout((int) (v.millis())); } catch (IOException e) { throw IOErr.make(e); } }
public void setLinger(TcpSocket fan, Duration v) { try { if (v == null) socket.setSoLinger(false, 0); else socket.setSoLinger(true, (int) (v.sec())); } catch (IOException e) { throw IOErr.make(e); } }
public Duration getReceiveTimeout(TcpSocket fan) { try { int timeout = socket.getSoTimeout(); if (timeout <= 0) return null; return Duration.makeMillis(timeout); } catch (IOException e) { throw IOErr.make(e); } }
public Duration getLinger(TcpSocket fan) { try { int linger = socket.getSoLinger(); if (linger < 0) return null; return Duration.makeSec(linger); } catch (IOException e) { throw IOErr.make(e); } }
public TcpSocket connect(TcpSocket fan, IpAddr addr, long port, Duration timeout) { try { // connect int javaTimeout = (timeout == null) ? 0 : (int) timeout.millis(); socket.connect(new InetSocketAddress(addr.peer.java, (int) port), javaTimeout); connected(fan); return fan; } catch (IOException e) { throw IOErr.make(e); } }