Have you tried adding carriage return to socket_write($socket, "message 1\r\n");at the end of the message? In many cases, when working with buffers and threads, this seems to do the trick.
Something else worth doing:
socket_write($socket, 'message 1'."\r\n".chr(0));
usleep(5);
socket_write($socket, 'Foobar'."\r\n".chr(0));
just giving a little extra time to flush the buffer can do wonders.
EDIT
I had another brain wave: did you also try to use the extra length parameter?
socket_write($socket, 'message 1'."\r\n".chr(0),strlen('message 1'."\r\n".chr(0)));
source
share