Skip to content

Instantly share code, notes, and snippets.

@jpauli
Created March 22, 2012 14:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpauli/2158791 to your computer and use it in GitHub Desktop.
Save jpauli/2158791 to your computer and use it in GitHub Desktop.
Simple PHP chat using nc
<?php
$p = proc_open("/bin/nc -l -p 11111", array (STDIN, array("pipe", "w"), array("file", "/dev/null", 'w')), $pipes);
while (1) {
$read = array($pipes[1]);
$write = $except = null;
stream_select($read, $write, $except, 2);
echo fgets($pipes[1]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment