Skip to content

furkanmustafa/FMSocket.php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

FMSocket.php

Easy to use wrapper for php socket functions.

Simple TCP Server:

$server = FMSocket::TCPStreamServer();
$server->listen('localhost', '8192');
$server->queue(FMSocket::QUEUE_LISTEN, function($serverSocket, $clientSocket) {
    static $connections = 0;
    $connections++;
    echo "New Connection! Greeting..\n";
    $clientSocket->send("SEE YOU!\n");
    $clientSocket->close();
    if ($connections >= 3) {
        $serverSocket->close();
        echo "Also closing the server";
    }
});
echo "Waiting for connections ..\n";
FMSocket::Loop();
echo "Done.\n\n";

Simple Unix Domain Sockets Server:

// Just change the listening part
$server = FMSocket::UnixSocketServer();
$server->listen('/Users/furkan/test.sock');

TODO

  • Basic implementation for multiple TCP/UDS connections with callbacks
  • Detect Disconnect
  • Libev Support
  • Pipelining
    $parser = new HTTPParser();
    $socket->pipe($parser);

LICENSE

GPLv3, See LICENSE

About

Easy to use wrapper for php socket functions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages