Re: Help getting a socket to work?

From: Martin (martinvalley_at_comcast.net)
Date: 09/03/04


Date: Thu, 02 Sep 2004 17:30:50 -0700

Andy / Daniel -

Thanks.

>Mayeb you found another program that is broken by SP2 :)

yeah, very well could be.

>
>> echo "Reading response: <br><br>";
>> while ($out = socket_read($socket, 999, PHP_NORMAL_READ)) {
>> echo $out;
>> }
>
>
>This blocks untill:
>- 999 bytes are read.
>- a \n, \r or \0 is received
>
>Are these conditions met?

No, they weren't. I didn't know I needed to do that. When I added \n
to the message from the server, the script started working all the way
through. However, I'm still getting an error on the socket_read. It
says: "unable to read from socket. operation completed successfully."

I tried taking the socket_read out of the "while" construct but it
didn't make any difference.

I found a comment on the PHP.net site that said that socket_read
doesn't work in Windows (the comment is nearly a year old). The writer
says to use: socket_recv instead. I tried it thus:

$rcd=socket_recv($socket,$buffer,999,0);
  echo $rcd;
  echo "<br>" . $buffer;

It worked!

Howeer, this appears to NOT wait on any terminating character. Since
it's possible for tcp/ip to break up the messages, I'm concerned that
I'll always receive complete messages. (I've had problems with that in
the past).

>BTW why socket_* and not fsockopen?

Because I don't know any better. Should I be using it?

Any other advice and guidance will be greatly appreciated.

Thanks again.



Relevant Pages

  • Re: "clear plays bad, end of story"
    ... >> never sinks to name-calling or gets rude. ... >>> Yeah, maybe you're right. ... lol. ... >>> Andy ...
    (rec.games.pinball)
  • Re: FEMA has been harmed by Bush administration-- Civil Servants speak out
    ... Andy writes: ... Yeah. ... real story, one has to question the people at the bottom.... ... charge who spend their time holding meetings asking the ...
    (soc.retirement)
  • RE: Cancel Error Message and resume
    ... Yeah, he could do that. ... in VBA? ... "Daniel" wrote: ... Is there script I can add that will ignore the error and resume the ...
    (microsoft.public.access.formscoding)
  • Re: Sail repair Boston area?
    ... Yeah, Andy that's nice. ... Can you send me your phone number so I can post it on the internet ... I think the protocol would be to provide a phone number in a private ...
    (rec.windsurfing)
  • Re: Illegal Immigration
    ... The 54 BILLION in the Senate bill, ... illegal Mexican in the US, will go a long way toward a wall.... ... Yeah, the government could probalby pull that off.. ... Andy in Eureka, Texas ...
    (soc.retirement)

Loading