Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
How to communicate between Python3 and JavaScript via sockets

I just set up a small TCP-socket server in python3, which waits for a connection, sends a small encoded text and waits for data from the client.

Python-Code:

import socket

sock = socket.socket()
sock.bind(("0.0.0.0", 20000))

sock.listen(5)

while True:
    Client, address = sock.accept()
    Client.send("ping".encode())
    print(Client.recv(1024).decode())  # Here I want to receive data from the client
    Client.close()

At the end, there should be a browser interface which can communicate with the python backend with JQuery or just something that receive and send (With data!) sockets.

Thank you :D

EDIT:

Forgot to say that I can receive the text in a browser, I just need to know how to send data back.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

if you need to connect to a NodeJS javascript environment then you should take a look at this native package https://nodejs.org/api/net.html#class-netsocket

if you need to connect to a browser javascript environment then you should take a look at WebSockets

  • Python: https://websockets.readthedocs.io/en/stable/#:~:text=websockets%20is%20a%20library%20for,an%20elegant%20coroutine%2Dbased%20API.
  • Javascript https://developer.mozilla.org/es/docs/Web/API/WebSockets_API
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda