protected void connect() {
		try {
			boolean received = false;
			for (int rounds = 0; !received && rounds < MAX_ROUNDS; ++rounds) {
				int transaction_id = random.nextInt();
				
				DatagramPacket sentPacket = url.makePacket(getRawConnectMessage(transaction_id).array());
				try {
					this.socket.send(sentPacket);
				} catch (IOException e) {
					e.printStackTrace();
				}
				
				DatagramPacket packet = url.makePacket(new byte[256]);
				try {
					this.socket.setSoTimeout((int) (15000 * Math.pow(2, rounds)));
					this.socket.receive(packet);
					
					ByteBuffer buffer = ByteBuffer.wrap(packet.getData());
					int action = buffer.getInt();
					int received_tid = buffer.getInt();
					long received_cid = buffer.getLong();
					
					if (action == ACTION_ID_CONNECT && received_tid == transaction_id) {
						this.connection_time = System.currentTimeMillis();
						this.connection_id = received_cid;
						received = true;
					}
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		} catch (UnknownHostException ex) {
			ex.printStackTrace();
		}
	}