Guest User

Untitled

a guest
Apr 25th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public void connect(InetAddress remoteAddress, int remotePort) throws IOException, SocketTimeoutException {
  2.  
  3. this.remoteAddress = remoteAddress.getHostAddress();
  4. this.remotePort = remotePort;
  5.  
  6. KtnDatagram syn = this.constructPacket(KtnDatagram.SYN, "heisann");
  7.  
  8. state = SYN_SENT;
  9.  
  10. KtnDatagram synAck = this.sendPacket(syn);
  11.  
  12. if (synAck != null) {
  13. state = ESTABLISHED;
  14.  
  15. this.remoteAddress = synAck.getSrc_addr();
  16. this.remotePort = synAck.getSrc_port();
  17.  
  18. state=ESTABLISHED;
  19. this.sendAck(synAck, KtnDatagram.ACK);
  20. } else {
  21. state = CLOSED;
  22. }
  23.  
  24. }
Add Comment
Please, Sign In to add comment