Bug #6200 Updated: fputs doesn't send, do not fflush after fgets.

From: Date: Sun, 22 Jul 2001 01:54:50 +0000
Subject: Bug #6200 Updated: fputs doesn't send, do not fflush after fgets.
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-60541@lists.php.net to get a copy of this message
ID: 6200 Updated by: andy Reported By: kh.wild@wicom.at Old Status: Open Status: Closed Bug Type: Sockets related Operating System: Linux 2.2.14 PHP Version: 4.0.1pl2 New Comment: Please upgrade to the latest version and try the script again. Re-open if problem still exists. Previous Comments: ------------------------------------------------------------------------ [2001-01-30 05:00:48] sniper@php.net reclassify ------------------------------------------------------------------------ [2000-08-17 04:42:03] kh.wild@wicom.at I have to communicate with a perl daemon that gives me an hash when I connect the port. After that I have to complete the data with this hash an send it in the same connection back to the daemon. What I have todo is a fgets for the first string and after sending the comleted data with an fputs. The daemons never receive my data's after the fputs. I tried the newest snap to use the fflush. But this didn't solve the problem. ------------------------------------------------------------------------ [2000-08-16 14:10:33] derick@php.net that's a nice piece of code, but totally useless. COuld you clarify it bit more? ------------------------------------------------------------------------ [2000-08-16 14:02:57] kh.wild@wicom.at $fd = fsockopen( $server, $port, &$errno, &$errstr ); if( ! $fd ) { print( "Couldn't connect to $server, errno: $errno, errstr: $errstr<br>\n" ); exit; } set_socket_blocking( $fd, false ); $ret = ''; while( ! feof( $fd ) ) { $ret .= fgets( $fd, 128 ); } if( trim( $ret ) <> '' ) { $key = strip_crlf( $ret ); } else { print( "Couldn't get key<br>\n" ); exit; } print( "got key: ---$key---<br>\n" ); $hash = md5( "$passwd.$key" ); $tmp = "$serviceid:$username:$hash"; fputs( $fd, "$tmp\n", strlen( $tmp ) + 1 ); fflush( $fd ); $ret = ''; while( ! feof( $fd ) ) { $r = fgets( $fd, 128 ); print( "-" . $r . "-" ); $ret .= $r; } print( "received id: $ret<br>\n" ); fclose( $fd ); ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=6200&edit=1

« previous php.dev (#60541) next »