Hi and thank you,

I noticed it has '*Return Values*' section for each section but for
the *Example
#1* / *Example #2*  etc don't seem to have the output with it.

For example: *http://www.php.net/manual/en/sockets.examples.php
<http://www.php.net/manual/en/sockets.examples.php>* (Below code)

There does not seem to have a output of what this does or am I just not
seeing it?


#!/usr/local/bin/php -q
> <?php
> error_reporting(E_ALL);
>
> /* Allow the script to hang around waiting for connections. */
> set_time_limit(0);
>
> /* Turn on implicit output flushing so we see what we're getting
>  * as it comes in. */
> ob_implicit_flush();
>
> $address = '192.168.1.53';
> $port = 10000;
>
> if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
>     echo "socket_create() failed: reason: " . socket_strerror(
> socket_last_error()) . "\n";
> }
>
> if (socket_bind($sock, $address, $port) === false) {
>     echo "socket_bind() failed: reason: " . socket_strerror(
> socket_last_error($sock)) . "\n";
> }
>
> if (socket_listen($sock, 5) === false) {
>     echo "socket_listen() failed: reason: " . socket_strerror(
> socket_last_error($sock)) . "\n";
> }
>
> do {
>     if (($msgsock = socket_accept($sock)) === false) {
>         echo "socket_accept() failed: reason: " . socket_strerror(
> socket_last_error($sock)) . "\n";
>         break;
>     }
>     /* Send instructions. */
>     $msg = "\nWelcome to the PHP Test Server. \n" .
>         "To quit, type 'quit'. To shut down the server type 'shutdown'.\n"
> ;
>     socket_write($msgsock, $msg, strlen($msg));
>
>     do {
>         if (false === ($buf = socket_read($msgsock, 2048, PHP_NORMAL_READ
> ))) {
>             echo "socket_read() failed: reason: " . socket_strerror(
> socket_last_error($msgsock)) . "\n";
>             break 2;
>         }
>         if (!$buf = trim($buf)) {
>             continue;
>         }
>         if ($buf == 'quit') {
>             break;
>         }
>         if ($buf == 'shutdown') {
>             socket_close($msgsock);
>             break 2;
>         }
>         $talkback = "PHP: You said '$buf'.\n";
>         socket_write($msgsock, $talkback, strlen($talkback));
>         echo "$buf\n";
>     } while (true);
>     socket_close($msgsock);
> } while (true);
>
> socket_close($sock);
> ?>
>


With kind regards and thank you for your prompt reply,








On Mon, Jun 16, 2014 at 12:03 PM, Hannes Magnusson <
[email protected]> wrote:

> On Sat, Jun 14, 2014 at 10:14 PM, Ansego <[email protected]> wrote:
> > Hi guys,
> >
> >
> > ~ First great job!
> >
> > Had a suggestion about the website, if possible could you guys do outputs
> > on the examples shown to help us newbs have a better understanding with
> > what it meant to do. I know some would think there is no point to do such
> > things, but I think it will have a huge positive impact for the next
> > generation of coders to learn php...
> >
>
>
>
> We do try to do that. Even for functions that return variable results,
> we state before the example output "returns similar to...".
> In certain cases the examples have inline comments about the return
> value, when listing the return value separately would be confusing.
>
> Do you have an concrete example this is not the case?
>
> -Hannes
>

Reply via email to