예제 #1
0
 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);
   }
 }
예제 #2
0
 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);
   }
 }
예제 #3
0
 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);
   }
 }
예제 #4
0
 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);
   }
 }
예제 #5
0
 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);
   }
 }