Re: How to get input from socket client
| From: | Ryan Sun | Date: | Thu, 20 May 2010 21:21:44 +0000 |
| Subject: | Re: How to get input from socket client | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-305371@lists.php.net to get a copy of this message | ||
Thanks for your reply
> First, I don't think feof() will do what you think it does. I
> wouldn't expect it to show up until after the other end has actually
> closed the connection.
I found unread_bytes in stream_get_meta_data should be more reliable
> TCP is a stream protocol, there
> are no guarantees about delivering a complete message in one read, or
> that two writes won't be read together. It only guarantees that all
> octets will eventually be delivered in the same order they were sent, or
> you will get an error.
thanks 4 pointing out the difference between tcp and udp, I had learnt a lot ^^
>The other problem has to do with thinking an fread() will always give
>you everything you sent in an fwrite()
Interestingly, I use 'telnet 127.0.0.1 1037' for testing later(on
windows) and everything works, the php server got the input from
telnet client, so I assume there is something wrong in the php client,
the fwrite statement...