Well, write a client using the socket functions (per the URL above) and just read the buffer. Then apply your filter using preg_match() or whatever and log the data.
Note that you must do this a command-line script (the PHP CLI), if you plan to be running the process for a long period of time. If not, and you want to output something from the remote host to a browser - this should be fine as long as the connection timeout is short.