Socket wrapper using streams for PHP