Guest User

Untitled

a guest
Jul 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. client.connect(LOGINPORT, LOGINHOST, function(){
  2. console.log("Connected to TCP server");
  3. client.write(JSON.stringify(loginData));
  4. });
  5.  
  6. client.on("data", function(data){
  7. console.log("Received from TCP server", data.toString());
  8. client.end();
  9. });
  10.  
  11. client.on("close", function(){
  12. console.log("Connection closed");
  13. });
  14.  
  15. app.get('/getUdpData', (req, res) => {
  16.  
  17. client.on('message', function(msg, info) {
  18. console.log('Data received from server : ' + msg.toString());
  19. console.log('Received %d bytes from %s:%dn', msg.length, info.address, info.port);
  20. res.send(msg);
  21. });
  22.  
  23. //sending msg
  24. client.send(JSON.stringify(newMsg), 6960, '10.221.49.71', function(error) {
  25. if (error) {
  26. client.close();
  27. } else {
  28. console.log('Data sent !!!');
  29. // client.close();
  30. }
  31. });
  32. });
Add Comment
Please, Sign In to add comment