Socket connections

From: Date: Fri, 30 Jun 2000 23:02:53 +0000
Subject: Socket connections
Groups: php.general 
Request: Send a blank email to php-general+get-4197@lists.php.net to get a copy of this message
I'm having a bit of trouble getting PHP to communicate over a socket connection. The server that I want it to communicate with works fine, and fsockopen() succeeds immediately. However, there seem to be some issues with fgets(). When I specify a string length up to the size of the data available on the stream, it works fine. However, if the buffer size is greater than that, fgets doesn't return, even in non-blocking mode, and it doesn't stop at the end of the line as the manual says it should. If I wait about a minute (which, interestingly enough, is far past the maximum execution time), fgets finally returns with the data. Of course, since this is a socket, I can't get the size of the data available, so I can't solve the problem that way. When I use a loop with fgetc() and feof(), the same thing happens, although I haven't performed an experiment to determine whether it's getting hung up on fgetc() or feof(). I also tried a do...while loop with fgets() and blocking off, but that didn't work either, and furthermore, it requires that I add a delay to prevent the loop from chewing up CPU time. At first I thought I must have been missing something, but when I tried a few scripts written by other people that used the same functions, they failed as well. I suspect there's some server configuration that needs to be changed. PHP and Apache are running on a FreeBSD box, and although I don't have physical access to the server, there doesn't seem to be anything in the network that prevents it from connecting to another server. I logged in via telnet, and then used the telnet program on the server to connect to the third site I'm trying to access, and it worked fine. Sorry for the verbosity. "I would have written you a shorter letter, but I didn't have the time." Does anyone have any ideas? TIA. Regards, David Schultz

« previous php.general (#4197) next »