Please consider my comments to the question as a big warning against this approach.
If you still want to use it, please see:
Try to find some more:
[EDIT: in response to PHP-related discussion in comments:]
This is how you can do it in PHP. For server side, with PHP in particular, custom networking is way more usual, by the reasons I tried to explain in comments to the question (please see the on on PHP) and this answer: