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

372
Views
¿Cómo obtener el enlace del servidor creado en la función http.createServer()?

¿Cómo obtener el enlace del servidor creado en la función http.createServer()?

Estoy tratando de usar el paquete http de node.js y uso la función createServer(), luego quiero imprimir el enlace del servidor con el puerto, así:

 const createServer = http.createServer(); const server = createServer.listen(port);

Y luego obtenga el enlace de la variable createServer como http://localhost o desde un enlace repl.it/replit.com. este es mi código en JS:

 const port = 1234; const createServer = http.createServer(); const server = createServer.listen(port); const websocket = new web({ httpServer: server }); console.log(createServer); // This doesnt print the server link
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede obtener la información sobre el servidor llamando a server.address() :

 console.dir(server.address()); //{ address: '::', family: 'IPv6', port: 1234 }

Dado que no especificó un host al crear el servidor, se utilizará el predeterminado que, según la documentación :

Si se omite host, el servidor aceptará conexiones en la dirección IPv6 no especificada (::) cuando IPv6 esté disponible, o la dirección IPv4 no especificada (0.0.0.0) en caso contrario.

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!