|
Posted by Adam on 09/26/05 04:58
On Fri, 23 Sep 2005 10:07:59 -0500, Jerry Stuckle wrote:
>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.
Well ... the story continues <ggg>. Basically though, it appears that
whichever way I try to read the data, it hangs. This is using fread,
fgets, socket reads ... you name it. The *impression* I get is that
the packet has already been and gone - and all attempts to read the
socket fail - because the [remote] server is no longer sending.
I know (via the portsniffer) that the incoming packet is less than 100
bytes long. It's not a file (I don't think) so it won't have an eof
marker.
I've just installed PHP5 with socket support on a Linux machine to see
whether any of the socket_* commands or new PHP5 functions will work.
Watch this space <g> ...
Adam.
[Back to original message]
|