Questions tagged [python-sockets]

For questions related to the sockets module in the Python standard library, or more broadly socket programming in Python.

The Python library comes with a HOWTO document for sockets programming:

Socket Programming HOWTO — Python 3.x documentation

The standard library is well-documented:

socket - Low-level networking interface

Like the title suggests, sockets are the basic facility for network connections, and on Unix, several other types of interprocess connections. Beginners who want to use a particular application-level protocol should often try to find an existing higher-level library for that instead of programming directly with sockets.

506 questions
1
vote
1 answer

how to share data between django server and python websocket server

I am writing a web app with Django in which I have to share some data with another python socket server running in parallel. I have tried using a common python file to store global variable. but since those server are two different processes it is…
Usama
  • 159
  • 1
  • 13
1
vote
1 answer

What is it wrong with my server (Python sockets)?

I started a project that aims to do a multiplayer Tic-Tac-Toe through sockets. In the first step of this project, I've coded the server and the client so that players can connect to server. But for some reason the server is only accepting one…
Aitor Ruiz
  • 11
  • 1
1
vote
1 answer

python sockets send file function explanation

I am trying to learn python socket programming (Networks) and I have a function that sends a file but I am not fully understanding each line of this function (can't get my head around it). Could someone please explain line by line what this is…
BarCode
  • 53
  • 1
  • 1
  • 5
1
vote
0 answers

python socket OSError: [WinError 10038] Ein Vorgang bezog sich auf ein Objekt, das kein Socket ist

I get the following error: Traceback (most recent call last): File "D:\Programmieren\Python\Sprach Assistent (v3)\Server\server.py", line 45, in runserver() File "D:\Programmieren\Python\Sprach Assistent (v3)\Server\server.py", line…
TheMiCraft
  • 11
  • 2
1
vote
2 answers

Receive multiple files simultaneously

I wrote a script in Python 3.8.6 to send and receive files between different devices. I am sending and receiving files normally, the problem happens when I receive multiple simultaneous connections from different devices. I configured the script to…
GConelhero
  • 126
  • 8
1
vote
0 answers

How can I establish socket connection between Python processes (for inter-process communication) while using a Flask webserver

I'm relatively new to Python and have been trying to figure out what I'm doing wrong here. I have a python script whose sole purpose is to control a piece of hardware. This controller script's main function runs in a continuous loop and each…
irtemed88
  • 333
  • 1
  • 3
  • 11
1
vote
0 answers

Sending separate data packets to clients [Python - Sockets]

I'm trying to write a server-client(s) program in python using the socket and the threading module. I would like to send and receive to and from the client a confirmation data packet to check if it is still connected to the server and,…
1
vote
1 answer

Retrieving unpack requires a buffer of 8 bytes error socket python

I have the following code I am sending the result of intermediate predictions results from the client to server. Client server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host_name = socket.gethostname() host_ip =…
eman davis
  • 23
  • 8
1
vote
1 answer

Socket for push notification

For my current web (reactJS) app, i need to implement a push notification system. Backend APIs are written in Python on Django Framework. So how should i implement socket, should I write in python, or may I write in node or node for the…
Arafat Ahmed
  • 145
  • 3
  • 10
1
vote
1 answer

python socket pickled numpy data not showing up

I'm trying to send python-opencv frames over sockets. I'm pickling the data and unpickling but for some reason it's blank or nothing is showing up. This is my terminal when I run client.py new message length: b'720 ' It should be streaming…
throw333
  • 13
  • 2
1
vote
3 answers

TypeError: a bytes-like object is required, not 'str' when I'm inputting command in console

I'm trying to connect to a server using socket module in python. However, I get an error message as shown below. TypeError: a bytes-like object is required, not 'str' Here's my code: import socket HOST = '0.0.0.0' PORT = 12345 server_socket =…
silent whatefver
  • 13
  • 1
  • 1
  • 3
1
vote
0 answers

Why it take so much time for the server to receive a message? Python socket

I am trying to code a simple share screen script. For some reason it take a lot of time for the server to receive the message. And I dont know what is the problem. If you have a solution, or a way to speed the process up it be very helpful. Any way…
1
vote
2 answers

Send dictionary in python socket

I want to send dictionary via python socket. I tried to encode sending data and then encode at the receiving point but the problem in unconvertable received data and can not convert to dictionary. Here is my code: Class client.py: HEADER_LENGTH =…
Hossein Kurd
  • 3,184
  • 3
  • 41
  • 71
1
vote
2 answers

How do I create a multiprocessed socket server?

I'm working on a socket server for this bot I'm building. My idea is to have multiple clients handle certain tasks. One observer, a calculator, and a trader. I want these to communicate with each other by creating a socket server. I'm using…
1
vote
1 answer

Firewall is not allowing my python client application to connect to a server running on my machine even after I turn off firewall completely

I am learning about the python socket library and am running into problems whenever I try to connect to the server running on my localhost with a client application. Here is the server code: import socket HOST = '127.0.0.1' # Standard loopback…