Skip to content

master and localsocket

Vladimir Goncharov edited this page Jul 13, 2016 · 3 revisions

websocket is used for generale use, localsocket and master are used for advanced use.

"websocket" creates server socket support websocket protocol.
"localsocket" creates server socket with telnet protocol.
"master" connects to "localsocket" with telnet protocol.

telnet is used for a simple internal communication between scripts

Examples:

  1. master-worker https://github.com/morozovsk/websocket-examples/tree/master/chat2
    master.php create server socket with telnet protocol on port "localsocket"
    worker.php create server socket with websocket protocol on port "websocket", also it connects to socket "master"

i.e master.php:localsocket = worker.php:master

worker.php receives data from "websocket" and sends data to the "master".
master.php receives data from "localsocket" and forwards data to other workers.
worker.php other workers receives data from "master" and forwards data to "websocket".

  1. websocket-database
    websocket.php create server socket with websocket protocol on port "websocket", also it creates server socket with telnet protocol on port "localsocket"
    database.php connects to socket "master"

i.e websocket.php:localsocket = database.php:master

websocket.php receives data from websocket-clients and sends data to the "localsocket".
database.php reads asynchronously from "master" data, does synchronously query to database and sends asynchronously result from database to "master".
websocket.php reads asynchronously from "master" data and sends to "websocket".

Clone this wiki locally