これが私のコードです:
var express = require('express');
var net = require('net');
var app = express();
//first of all connect to a stable client
var server = net.createServer(function(socket) {
// do nothing here . what i want is to use this socket in
// (following) app.get() function
});
server.listen(1337, '127.0.0.1');
//receive request from other clients
app.get('/', function (req, res)
{
// retriving mobileNumber and message
var mobileNumber = req.query.mobileNumber;
var message = req.query.message;
//now i want to send this data to the stable client
// to which i have connected earlier.
res.end();
});
app.listen(6544);
新しい「/」リクエストが到着するたびに、以前に接続されたソケットにデータを送信したいと考えています。