Added a limit to how much data will be read from socket to avoid infinity loop errors in PHP