Almost working reading of incomming packets (it works only for the first packet at the moment)