note 22338 added to function.socket-read
| From: | graham at halodev dot com | Date: | Fri, 14 Jun 2002 05:40:53 +0000 |
| Subject: | note 22338 added to function.socket-read | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31847@lists.php.net to get a copy of this message | ||
I set out to create a simple echo test application thingy in win2k running 4.1.2
$socket = socket_create( AF_INET , SOCK_STREAM , SOL_TCP);
$isbind = socket_bind($socket, "127.0.0.1", 7878);
if (!($isbind)){
echo "Trouble Binding";
return 0;
}
socket_listen($socket, 10);
while(true){
$newsock = socket_accept($socket);
if ($newsock){
echo "socket connected...\n";
socket_write($newsock, "ECHO>");
$indata = socket_read($newsock, 512);
echo "$indata";
socket_write($newsock, "\n" . $indata . "\n LATER!");
echo "success";
socket_close($newsock);
socket_close($socket);
return 0;
}
else{
echo "screwed up\n";
return 0;
}
}
echo "done\n";
}
I attempted to get it to read a string (up to 512 chars) and then simply echo it. What it does is
grab one char, repeat it and quit. Any ideas on what I'm doing wrong?
--
http://www.php.net/manual/en/function.socket-read.php
http://master.php.net/manage/user-notes.php?action=edit+22338
http://master.php.net/manage/user-notes.php?action=delete+22338
http://master.php.net/manage/user-notes.php?action=reject+22338