[php] socket functions


// simple socket server
$sock = socket_create(AF_INET, SOCK_STREAM, 0) or die();
socket_bind($sock, 'localhost', 22444) or die();
socket_listen($sock); 

$client = socket_accept($sock); 

socket_write($client, 'welcome');

$read = socket_read($client, 1024); // line A

socket_write($client, strtolower($read)); // line B

socket_close($client); 
socket_close($sock); 

i tested this with flash’s xmlsocket, under both php5.0.2 and php4.3.9. three scenarios
1, without lines A and B, connected -> connection lost. no ‘welcome’ message was recieved.

2, with line A no B, connected -> waits client input -> client inputs ‘hello’ -> connection lost. no message was recieved.

3, with lines A and B, connected -> waits client input -> client inputs ‘hello’ -> connection lost. recieved ‘welcomehello’.

this behaviour is certainly not what i have intended. i expect that flash client would receive a ‘welcome’ message even socket server is without lines A and B.

is there a fix for this?