Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

353
Views
cómo convertir formato binario a cadena (big endian)

tengo un socket tcp y trato de obtener datos binarios desde allí y convertirlos en cadenas por nodo js

aquí está mi código

 const Net = require('net'); const port = 4000; const host = '0.0.0.0'; const client = new Net.Socket(); client.connect({ port: port, host: host }), function() { console.log('TCP connection established with the server.'); client.write('Hello, server.'); }; client.on('data', function(chunk) { console.log(chunk); client.end(); }); client.on('end', function() { console.log('Requested an end to the TCP connection'); });

y la salida es

<Búfer 82 44 53 53 76 57 37 56 4c 6d 62 ed 14 00 00 00 00 00 00 00 00 00 00 00 00 4c 05 e5 58 00 00 00 00 e1 8f 80>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que solo te falta configurar la codificación. Creo que todo lo que necesita hacer es client.setEncoding("utf8") después de declararlo, y debería funcionar. Si no es así, debería consultar una API de Buffer y experimentar con la transformación de sus datos binarios en diferentes formatos.

Aquí están las referencias útiles:

https://nodejs.org/api/net.html#event-data

https://nodejs.org/api/net.html#socketsetencodificacióncodificación

https://nodejs.org/api/buffer.html

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!