Reputation: 42504
I have to create a simple service on linux VPS (IP: 1.2.3.4). So whatever text/data will be sent to that linux server 1.2.3.4:6345 it will post that text/data to a website.
Some thing like
Server 1.2.3.4 listening at port: 6345
Received text: 'lng: 12.00, lat: 14.00, DeviceId: E8f4kakh'
/*I will convert text to proper query params*/
Post data to www.mywebsite.com/data
I have no idea about linux programming. Can I do this using node.js? or any other simple language?
Upvotes: 1
Views: 1694
Reputation: 17319
assuming you're talking about a tcp server:
var http = require('http');
var net = require('net');
var mywebsite = http.createClient(80, 'www.mywebsite.com');
var server = net.createServer(function (socket) {
socket.write("GPS relay server\r\n");
socket.on("data", function (data) {
console.log(data);
var request = google.request('POST', '/data',
{'host': 'www.mywebsite.com'});
request.end(convertTextToProperQueryParams(data));
request.on('response', function (response) {
socket.write('STATUS: ' + response.statusCode);
});
});
});
server.listen(6345);
console.log('server listening on port 6345');
function convertTextToProperQueryParams(data) {
return ProperQueryParams;
};
Upvotes: 1