Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void connect(InetAddress remoteAddress, int remotePort) throws IOException, SocketTimeoutException {
- try {
- if(remoteAddress != null) {
- this.remoteAddress = remoteAddress.getHostAddress();
- this.remotePort = remotePort;
- }
- KtnDatagram SYN = constructPacket(KtnDatagram.SYN, "lol");
- KtnDatagram SYN_ACK = sendPacket(SYN);
- this.state = SYN_SENT;
- if(SYN_ACK != null) {
- this.state = ESTABLISHED;
- this.sendAck(SYN_ACK, KtnDatagram.ACK);
- this.remoteAddress = SYN_ACK.getSrc_addr();
- this.remotePort = SYN_ACK.getSrc_port();
- }
- else {
- throw new Exception();
- }
- }
- catch(Exception e) {
- e.printStackTrace();
- e.toString();
- }
- }
Add Comment
Please, Sign In to add comment