devster / userv
Micro PHP library to build a socket server
dev-master
2014-01-06 16:15 UTC
Requires
- php: >=5.3.3
- ext-pcntl: *
This package is auto-updated.
Last update: 2024-11-29 02:28:11 UTC
README
Micro PHP Socket server library
! work in progress! For now only tested on ubuntu, PHP 5.4 This lib should be used only in CLI, because of the use of pcntl_fork
Quick usage
Create a php file and copy the code below.
require 'vendor/autoload.php'; use Userv\Server; use Userv\Connection\TelnetConnection; $serv = new Server('127.0.0.1', 23); $serv ->setConnection(new TelnetConnection) ->setHandler(function($conn) { $conn->writeln('Hello, welcome on this telnet server, bouya!'); $name = $conn->ask('What\'s your name? : '); $conn->writeln('Your name is '.$name); }) ; $serv->run();
Then run this file as CLI script: sudo php myserver.php
.
Now open a new terminal and try telnet localhost
.