#16877 [Com]: socket_read() only gets one character (no matter what length set)

2007-11-14 Thread mayazza at yahoo dot com
 ID:   16877
 Comment by:   mayazza at yahoo dot com
 Reported By:  webmaster at red-sub-tech dot ws
 Status:   No Feedback
 Bug Type: Sockets related
 Operating System: Windows 2000 Profesional
 PHP Version:  4.2.0
 New Comment:

socket_read function is working but socket_write is not. is there any
solution. i cannot send message from server using socket_write function.


Previous Comments:


[2007-02-16 13:12:55] adrxc at hotmail dot com

I had spent many hours leading with that same socket_read() bugs, in
Windows 2000 SP4. A way to "by-pass" the bugs is getting bytes in a
loop, and omitting 'type' at socket_read() call. See the following
simple telnet server:

set_time_limit (0);
ob_implicit_flush ();

$host = "127.0.0.1";
$port = 4100;

$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not
create socket\n");
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
$ret = socket_bind($socket, $host, $port) or die("Could not bind to
socket\n");
$ret = socket_listen($socket, 3) or die("Could not set up socket
listener\n");
$client = socket_accept($socket) or die("Could not accept incoming
connection\n");

$welcome = "\n\rWelcome!";
socket_write($client, $welcome, strlen ($welcome)) or die("Could not
send connect string\n");

while(1) {
/* Ask for next input */
$output = "\n\n\rWaiting for request ('quit' to end)... ";
socket_write($client, $output, strlen($output)) or die("Could not
write output\n");

/* Get user message. Warning: socket_read does NOT works here if third
parameter is given */
$input = '';
while(ord($i = socket_read($client, 1024)) != 13) {
$input .=  $i;
socket_write($client, $i, 1) or die("Could not write output\n");
}

/* End session? */
if($input=="quit") {
break;
}

/* Out message back */
$output = "\n\n\rYou say '$input'";
socket_write($client, $output, strlen($output)) or die("Could not
write output\n");
}

socket_close($client);
socket_close($socket);



[2007-02-03 15:31:20] info at tentoday dot com

This problem is still available. Currently testing on Windows XP
professional SP2. Is there any workaround available? Currently the
sockets are just not usable on Windows XP. I haven't tested on Windows
2003 but expect the same. Version used is: PHP 5.2.0.

Thanks for information!



[2005-07-09 22:40:32] firebuddy007 at ameritech dot net

ive got one system with xp home, and one with xp pro, and socket_read
only reads one character on BOTH systems
its rather frustrating



[2002-07-15 09:37:47] administrator at zinious dot com

Looks like a bug in the code.

I'm using Windows 2000 Server (same OS family) and am reading multiple
bytes of text at one read.



[2002-06-05 01:00:07] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/16877

-- 
Edit this bug report at http://bugs.php.net/?id=16877&edit=1


#16877 [Com]: socket_read() only gets one character (no matter what length set)

2007-02-16 Thread adrxc at hotmail dot com
 ID:   16877
 Comment by:   adrxc at hotmail dot com
 Reported By:  webmaster at red-sub-tech dot ws
 Status:   No Feedback
 Bug Type: Sockets related
 Operating System: Windows 2000 Profesional
 PHP Version:  4.2.0
 New Comment:

I had spent many hours leading with that same socket_read() bugs, in
Windows 2000 SP4. A way to "by-pass" the bugs is getting bytes in a
loop, and omitting 'type' at socket_read() call. See the following
simple telnet server:

set_time_limit (0);
ob_implicit_flush ();

$host = "127.0.0.1";
$port = 4100;

$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not
create socket\n");
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
$ret = socket_bind($socket, $host, $port) or die("Could not bind to
socket\n");
$ret = socket_listen($socket, 3) or die("Could not set up socket
listener\n");
$client = socket_accept($socket) or die("Could not accept incoming
connection\n");

$welcome = "\n\rWelcome!";
socket_write($client, $welcome, strlen ($welcome)) or die("Could not
send connect string\n");

while(1) {
/* Ask for next input */
$output = "\n\n\rWaiting for request ('quit' to end)... ";
socket_write($client, $output, strlen($output)) or die("Could not
write output\n");

/* Get user message. Warning: socket_read does NOT works here if third
parameter is given */
$input = '';
while(ord($i = socket_read($client, 1024)) != 13) {
$input .=  $i;
socket_write($client, $i, 1) or die("Could not write output\n");
}

/* End session? */
if($input=="quit") {
break;
}

/* Out message back */
$output = "\n\n\rYou say '$input'";
socket_write($client, $output, strlen($output)) or die("Could not
write output\n");
}

socket_close($client);
socket_close($socket);


Previous Comments:


[2007-02-03 15:31:20] info at tentoday dot com

This problem is still available. Currently testing on Windows XP
professional SP2. Is there any workaround available? Currently the
sockets are just not usable on Windows XP. I haven't tested on Windows
2003 but expect the same. Version used is: PHP 5.2.0.

Thanks for information!



[2005-07-09 22:40:32] firebuddy007 at ameritech dot net

ive got one system with xp home, and one with xp pro, and socket_read
only reads one character on BOTH systems
its rather frustrating



[2002-07-15 09:37:47] administrator at zinious dot com

Looks like a bug in the code.

I'm using Windows 2000 Server (same OS family) and am reading multiple
bytes of text at one read.



[2002-06-05 01:00:07] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".



[2002-05-04 19:06:00] [EMAIL PROTECTED]

Please try with CVS HEAD and report back. But do *not* rely on the
manuals sample script, they're outdated.



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/16877

-- 
Edit this bug report at http://bugs.php.net/?id=16877&edit=1


#16877 [Com]: socket_read() only gets one character (no matter what length set)

2007-02-03 Thread info at tentoday dot com
 ID:   16877
 Comment by:   info at tentoday dot com
 Reported By:  webmaster at red-sub-tech dot ws
 Status:   No Feedback
 Bug Type: Sockets related
 Operating System: Windows 2000 Profesional
 PHP Version:  4.2.0
 New Comment:

This problem is still available. Currently testing on Windows XP
professional SP2. Is there any workaround available? Currently the
sockets are just not usable on Windows XP. I haven't tested on Windows
2003 but expect the same. Version used is: PHP 5.2.0.

Thanks for information!


Previous Comments:


[2005-07-09 22:40:32] firebuddy007 at ameritech dot net

ive got one system with xp home, and one with xp pro, and socket_read
only reads one character on BOTH systems
its rather frustrating



[2002-07-15 09:37:47] administrator at zinious dot com

Looks like a bug in the code.

I'm using Windows 2000 Server (same OS family) and am reading multiple
bytes of text at one read.



[2002-06-05 01:00:07] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".



[2002-05-04 19:06:00] [EMAIL PROTECTED]

Please try with CVS HEAD and report back. But do *not* rely on the
manuals sample script, they're outdated.



[2002-04-27 15:07:18] webmaster at red-sub-tech dot ws

Note this script was taken DIRECTLY from the PHP Manual (which you guys
have yet to update with the new socket fixes). And I used this in
Windows with a batch file (only one line on the batch file:
@c:\PHP\php-cli.exe -q c:\php\server.php )

Script:

error_reporting (E_ALL);

/* Allow the script to hang around waiting for connections. */
set_time_limit (0);

/* Turn on implicit output flushing so we see what we're getting
 * as it comes in. */
ob_implicit_flush ();

$address = 'xxx.xxx.x.xxx;
$port = 1;

if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0) {
echo "socket_create() failed: reason: " . socket_strerror ($sock) .
"\n";
}

if (($ret = socket_bind ($sock, $address, $port)) < 0) {
echo "socket_bind() failed: reason: " . socket_strerror ($ret) .
"\n";
}

if (($ret = socket_listen ($sock, 5)) < 0) {
echo "socket_listen() failed: reason: " . socket_strerror ($ret) .
"\n";
}

do {
if (($msgsock = socket_accept($sock)) < 0) {
echo "socket_accept() failed: reason: " . socket_strerror
($msgsock) . "\n";
break;
}
/* Send instructions. */
$msg = "\nWelcome to the PHP Test Server. \n" .
"To quit, type 'quit'. To shut down the server type
'shutdown'.\n";
socket_write($msgsock, $msg, strlen($msg));

do {
if (FALSE === ($buf = socket_read ($msgsock, 2048))) {
echo "socket_read() failed: reason: " . socket_strerror
($ret) . "\n";
break 2;
}
if (!$buf = trim ($buf)) {
continue;
}
if ($buf == 'quit') {
break;
}
if ($buf == 'shutdown') {
socket_close ($msgsock);
break 2;
}
$talkback = "PHP: You said '$buf'.\n";
socket_write ($msgsock, $talkback, strlen ($talkback));
echo "$buf\n";
} while (true);
socket_close ($msgsock);
} while (true);

socket_close ($sock);



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/16877

-- 
Edit this bug report at http://bugs.php.net/?id=16877&edit=1


#16877 [Com]: socket_read() only gets one character (no matter what length set)

2005-07-09 Thread firebuddy007 at ameritech dot net
 ID:   16877
 Comment by:   firebuddy007 at ameritech dot net
 Reported By:  webmaster at red-sub-tech dot ws
 Status:   No Feedback
 Bug Type: Sockets related
 Operating System: Windows 2000 Profesional
 PHP Version:  4.2.0
 New Comment:

ive got one system with xp home, and one with xp pro, and socket_read
only reads one character on BOTH systems
its rather frustrating


Previous Comments:


[2002-07-15 09:37:47] administrator at zinious dot com

Looks like a bug in the code.

I'm using Windows 2000 Server (same OS family) and am reading multiple
bytes of text at one read.



[2002-06-05 01:00:07] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".



[2002-05-04 19:06:00] [EMAIL PROTECTED]

Please try with CVS HEAD and report back. But do *not* rely on the
manuals sample script, they're outdated.



[2002-04-27 15:07:18] webmaster at red-sub-tech dot ws

Note this script was taken DIRECTLY from the PHP Manual (which you guys
have yet to update with the new socket fixes). And I used this in
Windows with a batch file (only one line on the batch file:
@c:\PHP\php-cli.exe -q c:\php\server.php )

Script:

error_reporting (E_ALL);

/* Allow the script to hang around waiting for connections. */
set_time_limit (0);

/* Turn on implicit output flushing so we see what we're getting
 * as it comes in. */
ob_implicit_flush ();

$address = 'xxx.xxx.x.xxx;
$port = 1;

if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0) {
echo "socket_create() failed: reason: " . socket_strerror ($sock) .
"\n";
}

if (($ret = socket_bind ($sock, $address, $port)) < 0) {
echo "socket_bind() failed: reason: " . socket_strerror ($ret) .
"\n";
}

if (($ret = socket_listen ($sock, 5)) < 0) {
echo "socket_listen() failed: reason: " . socket_strerror ($ret) .
"\n";
}

do {
if (($msgsock = socket_accept($sock)) < 0) {
echo "socket_accept() failed: reason: " . socket_strerror
($msgsock) . "\n";
break;
}
/* Send instructions. */
$msg = "\nWelcome to the PHP Test Server. \n" .
"To quit, type 'quit'. To shut down the server type
'shutdown'.\n";
socket_write($msgsock, $msg, strlen($msg));

do {
if (FALSE === ($buf = socket_read ($msgsock, 2048))) {
echo "socket_read() failed: reason: " . socket_strerror
($ret) . "\n";
break 2;
}
if (!$buf = trim ($buf)) {
continue;
}
if ($buf == 'quit') {
break;
}
if ($buf == 'shutdown') {
socket_close ($msgsock);
break 2;
}
$talkback = "PHP: You said '$buf'.\n";
socket_write ($msgsock, $talkback, strlen ($talkback));
echo "$buf\n";
} while (true);
socket_close ($msgsock);
} while (true);

socket_close ($sock);



[2002-04-27 14:57:44] [EMAIL PROTECTED]

Please include a short, self-contained sample script (it works for me
with cvs head).



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/16877

-- 
Edit this bug report at http://bugs.php.net/?id=16877&edit=1