private void beginListening(String address, int port) {
        Socket s;

        try {
            s = new Socket(address, port);
        } catch (UnknownHostException ex) {
            onUnsuccessfulConnection();
            return;
        } catch (IOException ex) {
            onUnsuccessfulConnection();
            return;
        }

        server = prepareSocketContainer(s);

        onSuccessfulConnection();

        InputStream cstream;

        try {
            cstream = server.getSocket().getInputStream();
        } catch (IOException io) {
            System.out.println("Connection failed to be made with " + server.getSocket());
            return;
        }

        GenericDataInput gdis = new StreamWrapperDataInputStream(cstream);

        while (true) {
            //c.getSocket().getInputStream(); //check if the socket is STILL ALIVE!!
            byte sig = (byte) gdis.readByte();

            if (sig == -1) {
                onDisconnect();
                return;
            }

            boolean caught = onPacketRecieved(sig, gdis);

            //System.out.println("Finished handling packet "+sig);
            if (!caught) {
                onUnhandledByte(sig, gdis);
            }
        }
    }