Connect to socket.io (nodejs) via PHP

I needed to connect to websocket via php, send data and disconnect immediately. No need to wait for a response from the socket. I used elefant.io , but after updating the library does not work. Please tell me how to connect to websocket via PHP?

+4
source share
2 answers

I also ran into this problem. Learned a lot of web layout layout requests. I wrote a library for myself, you can use it. PHP SocketIO Client .

You need a simple socket plugged into nodejs arranged in this message format. 42["message", "your message"]'For encoding in hybi10 (or hybi13) and sending to websocket

+6
source
var socket = require( 'socket.io' );

var express = require( 'express' );

var http = require( 'http' );

var app = express();

var server = http.createServer( app );

var io = socket.listen( server );

io.sockets.on( 'connection', function( client ) {

console.log( "New client !" );
-3
source

All Articles