How would I use Socket.io on a dedicated node.js server on a php site? -


for web application coded in php, powering lot of functionality traditionally utilize ajax, real-time chat, socket.io. in order use websockets without straining apache servers, have servers running node.js websocket connections. intend use dnode allow php scripts call node.js websocket functions. how this? please provide simple example if possible.

i realize may not efficient structure, because of large number of connections utilizing real-time functionality @ same time, running websockets php server-intensive. know there other ways of achieving real-time communication between server , client, long polling , forever iframes, there specific reasons behind choice of websockets.

this alternative send data php node.js:

<?php  $ch = curl_init();  $data = array('name' => 'foo', 'file' => '@/home/user/img.png');  curl_setopt($ch, curlopt_url, 'http://localhost:8082/test'); /* nodejs */ curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $data);  curl_exec($ch); ?> 

more info here.

in app.js

app.post('/test', function(req, res){     console.log("name: " + req.body.name); ... 

i hope helpful.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -