Skip to content

Instantly share code, notes, and snippets.

@BenMorel
Created August 27, 2017 12:15
Show Gist options
  • Save BenMorel/efadaa0dad4927c6fcafdc66e8d28dbf to your computer and use it in GitHub Desktop.
Save BenMorel/efadaa0dad4927c6fcafdc66e8d28dbf to your computer and use it in GitHub Desktop.

Revisions

  1. BenMorel created this gist Aug 27, 2017.
    10 changes: 10 additions & 0 deletions server.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <?php

    $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
    socket_bind($sock, '0.0.0.0', 10000);

    for (;;) {
    socket_recvfrom($sock, $message, 1024, 0, $ip, $port);
    $reply = str_rot13($message);
    socket_sendto($sock, $reply, strlen($reply), 0, $ip, $port);
    }