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
votes
1 answer

OSError: [Errno 48] Address already in use despite using allow_reuse_address

I'm trying to create two separate HTTP Servers from a single python script. I have a setup as follows: app.py: app = Flask(__name__) can_routes = { "/": 0 } can_server = RemoteServer(host="127.0.0.1", port=9000, routes=can_routes,…
MilyMilo
  • 121
  • 1
  • 6
-1
votes
1 answer

KeyError when trying to access client

i have a code which needs to perform the task of sending and receiving messages from specific clients. When i mention the client address in the send function of the server, i am being given a key error. [NEW CONNECTION] ('10.14.0.1', 52870)…
Sho
  • 21
  • 5
-1
votes
1 answer

can't close socket connection on KeyboardInterrupt(Python)

I'm trying to close socket connection(currently I'm printing out classMember @ line 60) but it's not working on KeyboardInterrupt, What should I do?
Nop
  • 1
  • 1
-1
votes
1 answer

serving html with the socket module

I opened port 8080 using python socket: Sk.bind(ip_addrr, 8080) But I want it to open a html page in that port,so that when I navigate to :8080 in browser I must get a web page.Any ideas? my problem is that I need to get a html page which I…
Trapmap
  • 13
  • 2
-1
votes
2 answers

How to make python server public to other computers in a Linux machine?

I have an ubuntu computer and I want it to act as a server. How do I need to configure the ubuntu computer to be accessible from other computers? Let's say I have this very simple python TCP server: from socket import socket with socket() as…
Itay Dumay
  • 139
  • 10
-1
votes
2 answers

Starting a TCP client with python

I'm learning ethical hacking with Python, and I have been trying to type a simple TCP client from BlackHat python book, but I have problems running the code I have written from the book. import socket target_host = "95.127.145.5" target_post =…
-1
votes
2 answers

How to connect two computers on the internet using Python sockets?

Whatever tutorials I've read online dictate how to connect two computers on a local network. What I want to do is connect my Android phone (I have a terminal emulator on it which has Python installed -- Termux), to my computer. Server --> Android…
zombiesauce
  • 1,009
  • 1
  • 7
  • 22
-1
votes
1 answer

How to send file using third argument in Python Socket?

I'm just new to Python Socket~ I'm making a socket project which can send a file to the server, and I would like to make to client execution like so: python client.py [hostname] [port] [send filename] sys.argv[1], sys.argv[2] are used to send…
Sai
  • 9
-1
votes
1 answer

timeout function in socket program in python

I am using settimeout() function in such way: import socket s.connect((host,port)) s.settimeout(1) #a try: while True: s.settimeout(0.030) #b try: code except socket.timeout: code …
54TY4M
  • 61
  • 1
  • 7
-1
votes
1 answer

Is there a way to bind DNS port 53 to only TCP or UDP specifically?

I need to keep dns port 53 busy/binded to a interface over only TCP or only UDP. is there a way to accomplish this? using socket lib python or any other way would be appreciated.
Sunil Kumar
  • 186
  • 3
  • 12
-1
votes
1 answer

Python3 TypeError: sequence item 0: expected a bytes-like object, int found

I'm trying to send an array over TCP from a server-like script to a client-like one. The array is variable, so the data is sent using packets and then joined together at the client. The data I'm trying to send is from the MNIST hand-written digits…
Meloku
  • 45
  • 1
  • 2
  • 9
-1
votes
2 answers

Python Socket: Storing 'connections'?

I have multi-threaded python socket server: connection, client_address = sock.accept() And i need to store 'connection' to use for other thread. How to do that?
Marek Grzyb
  • 177
  • 13
-1
votes
1 answer

debug child process running under control of entr

I'm trying to find a way to use remote_pdb and entr together as an environment for rapid testing and development of Python 3 multiprocessing applications, but they're not playing nicely together. Consider the trivial test case below: import…
Mike Ellis
  • 1,120
  • 1
  • 12
  • 27
-1
votes
1 answer

Python socket server for multiple connection handling

Can some one suggest a good example for socket server which can handle multiple connections with threading from python. (Live connection (like server-client ping-pong) that will handle from threads)
chinthakaS
  • 125
  • 1
  • 2
  • 10
-1
votes
1 answer

server doesn't send data to clients

I have this piece of code for server to handle clients. it properly receive data but when i want to send received data to clients nothing happens. server import socket from _thread import * class GameServer: def __init__(self): #…
Reza
  • 728
  • 1
  • 10
  • 28
1 2 3
33
34