Here is my web.js,I want it can send message to another server(coding by c++) when it get POST from a.php
web.js:
var http=require('http');
var express=require('express');
var fs=require('fs');
var net=require('net');
var app=express();
var server=http.createServer(app);
app.use(express.static(__dirname + '/public'));
app.use(express.bodyParser());
app.use(express.json());
app.post('/',function(req,res){
var HOST='127.0.0.1';
var PORT=9011;
var client=new net.Socket();
client.connect(PORT, HOST, function() {
console.log('Client Sent');
client.write('YO WTF');//Send message
});
req.on('error', function(e) {
console.lo`enter code here`g('fuck');
});
});
server.listen(7000,function(){
console.log('Web.js is listening at port 7000');
});
Maybe the problem is I use json ? or c++ should do something to handle json string??
it didn't work ,I don't know why,Please help me,thanks~
Aucun commentaire:
Enregistrer un commentaire