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

128
Views
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 answers
Answer question

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 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!