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
0 answers

Python socket.recv() hangs after connection drop

I have implemented a server in Python 3.8.6 using the socket library (running on a Raspberry Pi 4 w/ 8G RAM & Raspberry Pi OS: Buster) which, by design, only handles a single connection at a time. When a connection is gained, the server spawns two…
1
vote
0 answers

Websockets Client not printing message -- Python

The Connection is being established but no message is being printed to the terminal. Here is my code. import websocket, json cc = 'btcusd' interval = '1m' socket = f'wss://stream.binance.com:9443/ws/{cc}@kline_{interval}' print('This part of the…
Precious Chika
  • 119
  • 1
  • 2
  • 6
1
vote
1 answer

Python Socket - Server Stop after receive only one message

firstly sorry for my bad english (I'm French) because I'm trying to not use Google Translate. So, my problem is in the following set of server.py and client.py. Just a client that send every 10 seconds a message with a incremental counter on the…
1
vote
1 answer

Simple two way socket communication

I want to implement a simple two way communication between server and client using sockets. The Client sends messages and waits for replies. The Server reads messages and replies with appropriate results. I have the below codes, but both of them are…
torayeff
  • 9,296
  • 19
  • 69
  • 103
1
vote
0 answers

raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type bytes is not JSON serializable

i am having trouble with this code i dont know where the error is the client or the server this is the code def execute_command(self, command): que = subprocess.check_output(command, shell=True) return que def…
Nafiyad
  • 46
  • 1
  • 8
1
vote
1 answer

Qt and Web server app OSError: [WinError 10038] An operation was attempted on something that is not a socket

I was creating a pyqt app which will start a web server and view it by QWebEngineView. It uses http.server to create the webserver. It also uses multithreading to create the server. Here is my code of the app. import sys import threading from…
1
vote
1 answer

How can I open a Port with RAW-SOCKETS?

I am working on RAW-Sockets with AF_PACKET in Python3. If I send this DNS-Query Packet -> I get an answer, but: The Linux-Kernel sends an ICMP Destination unreachable (Port unreachable) because I didnt open the Source-Port 57799. How can I open a…
1
vote
0 answers

Checking for open ports in python

I am learning hacking from this tutorial on youtube. Around 1:11:30 (timestamp), he tries to check for open ports on the ip of his own router and on http://testphp.vulnweb.com. He gets 4 ports as open for each. When I run my code I only get port 80…
Arnav Mangla
  • 82
  • 1
  • 7
1
vote
0 answers

Broken Pipe in Python Sockets

I writing a simple application that reads each word from a text file and reports various statistics from about the words. One file reads through every word in the file and sends each word to the server using Python's socket library. This works fine…
Fiach ONeill
  • 155
  • 13
1
vote
1 answer

AWS Python socket client TimeoutError: [WinError 10060] A connection attempt failed

I have an aws ec2 instance where I am trying to create a server to bind with my windows application the ser works but whenever I try to connect to the server from the client on my pc it gives the following error: TimeoutError: [WinError 10060] A…
JashSmith
  • 211
  • 1
  • 15
1
vote
1 answer

Python Sockets: my recv protocol receive all the data when i debug it but not when i run it doesnt

So my project is that I need to send a jpg image from one computer to another computer in the same network. To send the data I split the data into chunks of at least 9999 bytes and then I create a length header that tells the length of the data and…
1
vote
0 answers

TLS Handshake times out ssl python

So I am trying to connect to different sites on the Internet through the proxy that I am currently trying to build. If I try to connect to a website on port 80 EVERYTHING works perfectly. But when I try to connect to any https link it does not…
Rag
  • 101
  • 1
  • 11
1
vote
1 answer

How to capture error messages via Python when inserting data in QuestDB?

Currently I am saving data to QuestDB through Python via the Influx Line Protocol (ILP) like so: import socket ilp_msg = 'my_table,name=server_timestamp value=12.4\n' sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: …
Newskooler
  • 3,973
  • 7
  • 46
  • 84
1
vote
1 answer

python socket, client not receiving data in order

So i'm writing a TCP based code in python that send 2 variables (username and password) from client and server receives those 2 variables and based on those variables, it does something, but my problem is that my client doesn't receive the second…
Morteza
  • 25
  • 1
  • 3
1
vote
0 answers

Tetris Game -Networking in python using sockets

I really need help on a project I'm currently doing. Basically I have a game of Tetris, and I want to implement a multiplayer function to it which will send the scores to each other's screen within a LAN. I've been trying so hard and it is still not…