|
Posted by Jerry Stuckle on 12/05/79 11:27
Adam wrote:
> On Thu, 22 Sep 2005 11:23:15 -0500, Jerry Stuckle wrote:
>
>
>
> Jerry - thanks for persevering with me on this one <g>. Yep - I'd read
> that warning in the manual.
>
> There's no problem with *writing* to the [opened] socket. Using a
> packet sniffer, I can see the data go out and - what's more - I can
> see a response packet appear on the client. This is what's happening:
>
> 1) Open socket (in client).
> 2) Write to socket (gets sent successfully to game server).
> 3) Client gets response back from server (socket still open).
> 4) Futile attempts to read the 67 bytes long incoming packet (!!).
> 5) Close socket (in client).
>
> For step 4, I've tried fread, fgets .. all sorts - but it occurs to me
> that this may be a PHP/OS related thing, as I've seen (in my Googling)
> reference to a *read* socket bug in PHP in earlier builds for Win32.
>
> Are you suggesting I send something [again] before steps 3,4? Is it a
> *timing* problem? Either the PHP script isn't waiting long enough for
> the incoming packet or the packet has beenand gone before the script
> has had a chance to read it?
>
> All examples I've tried using (eg. HTTP/port 80) seem to work fine - a
> request gets sent and the response is processed properly and
> displayed.
>
> My setup is Apache/2.0.52 (Win32) PHP/4.3.9. I'll try running the
> client script from a Linux machine.
>
> Adam.
Hi, Adam,
OK, I didn't realize you were sending to the remote machine first. OK,
so we know the socket itself is open, you can write to it, and you get a
response back.
Next thing - fread stops as soon as a packet is available. This may or
may not be the entire message. An extreme example - say the remote
system is sending you 100K worth of data. This won't all come in one
packet - you probably will have at least dozens of them. fread() will
read one packet, and you'll have to keep to keep receiving until you get
all the data, and assemble the packets.
How does this apply in your case? Well, is it possible you're getting a
short (or empty) packet before the data? It's perfectly legal for the
remote to do so. If so, you'll have to loop on your fread() call until
you get all 67 bytes of data.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|