Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client.connect(LOGINPORT, LOGINHOST, function(){
- console.log("Connected to TCP server");
- client.write(JSON.stringify(loginData));
- });
- client.on("data", function(data){
- console.log("Received from TCP server", data.toString());
- client.end();
- });
- client.on("close", function(){
- console.log("Connection closed");
- });
- app.get('/getUdpData', (req, res) => {
- client.on('message', function(msg, info) {
- console.log('Data received from server : ' + msg.toString());
- console.log('Received %d bytes from %s:%dn', msg.length, info.address, info.port);
- res.send(msg);
- });
- //sending msg
- client.send(JSON.stringify(newMsg), 6960, '10.221.49.71', function(error) {
- if (error) {
- client.close();
- } else {
- console.log('Data sent !!!');
- // client.close();
- }
- });
- });
Add Comment
Please, Sign In to add comment