Contributions are ready for review

[email protected]
Newsgroups php.doc.de
Message-ID <[email protected]>
Hello PHP DE Documentation team,

There are contributions within the online editor queue for this language.
Please review, then commit or delete these patches.

    Patches for review : 
    -----------------------

Modified: de/reference/sockets/examples.xml
By: cmb on 2017-08-01 07:51:34
===================================================================
--- de/reference/sockets/examples.xml
+++ de/reference/sockets/examples.xml
@@ -142,6 +142,105 @@
    </programlisting>
   </example>
  </para>
+ <para>
+  <example>
+   <title>Socket-Beispiel: Socket Server auf Unix/Linux</title>
+   <para>
+    Dieses Beispiel zeigt einen Socket Server auf Unix/Linux, der auf hereinkommende Verbindungen und Nachrichten antwortet.
+    Die Clients können mit Befehlen die Verbindung abbrechen oder den Socket Server herunterfahren.
+   </para>
+   <programlisting role="php">
+<![CDATA[
+#!/usr/local/bin/php -q
+<?php
+error_reporting(E_ALL & ~E_NOTICE);
+
+//  Erlaube dem Skript auf hereinkommende Verbindungs zu warten
+set_time_limit(0);
+
+//  Pfad zum Socket
+$socket_path = "/tmp/php_unix_test_server.sock";
+
+//  Socket Deskriptor erstellen
+if(!($sock = socket_create(AF_UNIX, SOCK_STREAM, SOL_SOCKET)))
+    die("socket_create() failed: reason: " . socket_strerror(socket_last_error()));
+
+//  Socket an /tmp/php_unix_test_server.sock binden
+if(!socket_bind($sock, $socket_path))
+    die("socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)));
+
+//  Auf hereinkommende Verbindungen zuhören
+if(!socket_listen($sock))
+    die("socket_listen() failed: reason: " . socket_strerror(socket_last_error($sock)));
+
+$clients = [];
+
+while(true){
+    //  $read für socket_select() vorbereiten
+    $read = [$sock];
+    if(count($clients) > 0)
+        $read = array_merge($read, $clients);
+    
+    //  Nach Änderungen suchen
+    $changes = socket_select($read, $write = null, $except = null, $tv_sec = 0);
+    
+    if($changes === false)
+        die("socket_select() failed: reason: " . socket_strerror(socket_last_error($sock)));
+
+    if($changes == 0){
+        //  Keine Änderung
+        sleep(1);
+        continue;
+    }
+    
+    //  Änderung erfasst
+    foreach($read as $socket){
+        switch($socket){
+            case $sock:
+                //  Neuer Client
+                $new_client = socket_accept($sock);
+                $message = "nWelcome to the PHP Unix Test Server. nTo quit, type 'quit', To shut down the server type 'term'.n";
+                socket_write($new_client, $message, strlen($message));
+                //  Client zum $client[] Array hinzufügen
+                $clients[] = $new_client;
+                break;
+            default:
+                //  Der Client hat etwas geschrieben
+                while($buf = socket_read($socket, 2048, PHP_NORMAL_READ))
+                    if($buf = trim($buf))
+                        break;
+                
+                switch($buf){
+                    case "quit":
+                        $key = array_search($socket, $clients);
+                        $message = "Tschüss!n";
+                        socket_write($socket, $message);
+                        socket_close($socket);
+                        unset($clients[$key]);
+                        break;
+                    case "term":
+                        $message = "Server wird heruntergefahren!n";
+                        foreach($clients as $client){
+                            socket_write($client, $message, strlen($message));
+                            socket_close($client);
+                        }
+                        socket_close($sock);
+                        unlink($socket_path);
+                        break 4;
+                    default:
+                        $message = "Sie haben geschrieben: $bufn";
+                        socket_write($socket, $message, strlen($message));
+                        break;
+                }
+                break;
+        }
+    }
+    sleep(1);
+}
+]]>
+   </programlisting>
+  </example>
+ </para>
 </chapter>
 
 <!-- Keep this comment at the end of the file


            => Put this change into your patches : https://edit.php.net/?project=php&action=putIntoMyPatches&idDB=74732
            => Delete this change: https://edit.php.net/?project=php&action=deleteThisChange&idDB=74732
            
                                          ------------------------------------------------------------------

Modified: de/reference/array/functions/array-map.xml
By: cmb on 2017-10-30 05:31:53
===================================================================
--- de/reference/array/functions/array-map.xml
+++ de/reference/array/functions/array-map.xml
@@ -148,7 +148,7 @@
 <?php
 function show_Spanish($n, $m)
 {
-    return("Die Zahl $n heißt auf Spanisch  $m");
+    return("Die Zahl $n heißt auf Spanisch $m");
 }
 
 function map_Spanish($n, $m)


            => Put this change into your patches : https://edit.php.net/?project=php&action=putIntoMyPatches&idDB=76003
            => Delete this change: https://edit.php.net/?project=php&action=deleteThisChange&idDB=76003
            
                                          ------------------------------------------------------------------




-- 
https://edit.php.net/
This email is send automatically by the Php Docbook Online Editor.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.