@Override
    protected void connected(Socket socket) {
        sock = socket;
        try {
			sock.setTcpNoDelay(true);
            try {
                sock.setTrafficClass(0x10);
            } catch(SocketException e) {
                System.out.println("Connection Error! >> " + e.getMessage());
            }
			socketOut = sock.getOutputStream();
			socketIn = sock.getInputStream();
			fireConnected();
			while (true) { //block until the socket is closed
				readLine(socketIn);
				if(!_isConnected) break;
			}
        } catch(SocketException e) {
            System.out.println("Connection Error! >> " + e.getMessage());
        } catch(Exception e) {
            System.out.println("Connection Error! >> " + e.getMessage());
        } finally {
            fireDisconnected();
        }

		try { socket.close(); } catch (Exception e) { System.out.println("Connection Error! >> " + e.getMessage()); }
		_isConnected=false;
		        
		//The sleep is to get around the socket still listening after being closed
		if(!destroy)
			System.out.println("AIBO Head Control :: connection closed... reconnecting");
		try { Thread.sleep(5000); } catch (Exception e) {}
  }