Commit 0a6bf0aecbb2410d3f1e3e90a7e1a0b46f842683
1 parent
c9b8362ad7
Exists in
master
cambios jose
Showing
1 changed file
with
4 additions
and
3 deletions
Show diff stats
index.js
| ... | ... | @@ -3,7 +3,7 @@ const Net = require('net'); |
| 3 | 3 | const converter = require('hex2dec'); |
| 4 | 4 | // The port number and hostname of the server. |
| 5 | 5 | const port = 10001; |
| 6 | -const host = '190.15.193.76'; | |
| 6 | +const host = 'fipdebo.ddns.net'; | |
| 7 | 7 | var respuesta = ''; |
| 8 | 8 | |
| 9 | 9 | // Create a new TCP client. |
| ... | ... | @@ -15,19 +15,20 @@ client.connect({ port: port, host: host }, function() { |
| 15 | 15 | console.log('TCP connection established with the server.'); |
| 16 | 16 | var code = String.fromCharCode(01); |
| 17 | 17 | // The client can now send data to the server by writing to its socket. |
| 18 | - console.info(client.write(code + 'i201TT')); | |
| 18 | + console.info(client.write(code + 'i20100')); | |
| 19 | 19 | }); |
| 20 | 20 | |
| 21 | 21 | // The client can also receive data from the server by reading from its socket. |
| 22 | 22 | client.on('data', function(chunk) { |
| 23 | 23 | var data = chunk.toString('utf8'); |
| 24 | + console.log('response', data); | |
| 24 | 25 | if (respuesta) { |
| 25 | 26 | respuesta += data; |
| 26 | 27 | } else { |
| 27 | 28 | var respuesta = data; |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | - if (data[data.length - 1].charCodeAt(0) == 3 && respuesta.slice(1,5) == 'i201') { | |
| 31 | + if (data[data.length - 1].charCodeAt(0) == 3) { | |
| 31 | 32 | var indice = 0; |
| 32 | 33 | var fecha = new Date(); |
| 33 | 34 | var respuesta = respuesta.slice(17, respuesta.length); |