Connect to socket.io(nodejs) via PHP

前端 未结 2 1390
别跟我提以往
别跟我提以往 2021-02-09 15:18

I had a need to connect to websocket via php, send data and immediately disconnect. No need to wait for a response from the socket. I used elefant.io but after updating the libr

2条回答
  •  遥遥无期
    2021-02-09 15:40

    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 !" );
    

提交回复
热议问题