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
3
votes
3 answers

Check if a socket is busy or not

I am new to Socket Programming in Python. I have written the following code in Python 3.7: trialSocketList.py import subprocess import sys HOST = sys.argv[1] PORT = sys.argv[2] command = "tnc " + HOST + " -PORT…
Code_Ninja
  • 1,729
  • 1
  • 14
  • 38
3
votes
1 answer

Send Continuous Data to Client from Server python

I am writing a program to send the data continuously to the Client from the Server. In here, i am using a timestamp for sample to send it to the multiple Clients who are connected. I have used multi-threading to support multiple Clients. I want the…
Smack Alpha
  • 1,828
  • 1
  • 17
  • 37
3
votes
1 answer

socket.accept() in python; How to set client side for the connection port

Instead on posting my mile long script here is a short example: I am creating a TCP/IP connection between two computers each running one of the following scripts: server: # server.py import socket s = socket.socket() host =…
SimpleJack
  • 33
  • 1
  • 4
3
votes
1 answer

Python socket recv data in while loop not stopping

While im trying to recv data with a while loop the loop not stopping even when there is no data import socket class Connect: connect = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def __init__(self, server_ip, server_port): …
dsal3389
  • 658
  • 1
  • 7
  • 26
3
votes
1 answer

How to avoid blocking when reading from a socket with python asyncio?

I'm trying to experiment a bit with python asyncio to improve in that area, for self teaching purposes I'm trying to connect to redis, send some commands and read the response, this can fall under generic "read a stream of data from some source".…
Mattia Procopio
  • 631
  • 8
  • 16
3
votes
1 answer

ssl.SSLZeroReturnError: TLS/SSL connection has been closed (EOF) (_ssl.c:661)

This is my code: import ssl, socket server ='10.10.10.9' port = 50443 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ssl_sock =ssl.wrap_socket(sock,ssl_version=ssl.PROTOCOL_SSLv3) ssl_sock.connect((server, port)) return ssl_sock I am…
Ragav_krish
  • 33
  • 2
  • 7
3
votes
1 answer

socket.send() is raising AttributeError: 'tuple' object has no attribute 'send'

I was developing a program that individual elements from the list to another machine (sender-server,reciever-client). I am sharing my program below -------------------------client.py------------------------ import socket # Import…
3
votes
2 answers

How to reslove "socket.gaierror" error of python-smtplib?

Few hours back I have posted a post related to "Django email sending API" and its error. So I thought that first I should try something with "smtplib". Unfortunately, after struggling with "smtplib", I realise that it will also not work, because…
jax
  • 3,927
  • 7
  • 41
  • 70
3
votes
2 answers

Is it safe to assume that socket.sendto is non-blocking operation?

I have a socket object created with socket(AF_INET, SOCK_DGRAM) which I will be using it in an asyncio loop. However I couldn't find sendto function in https://docs.python.org/3/library/asyncio-eventloop.html#low-level-socket-operations. Can I…
SpringMaple
  • 311
  • 3
  • 11
3
votes
0 answers

Python requests throwing SSLError while using local certificate

I'm writing a script to a server and verify it's certificate. If I write the script using sockets it works fine: import socket, ssl, pprint s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ssl_sock = ssl.wrap_socket(s, …
lalli
  • 6,083
  • 7
  • 42
  • 55
3
votes
2 answers

Broadcasting socket server in python

I am building a multiplayer game, so once the server started i want to broadcast server name continuously so that client can know that there are some server is running. I don't want to give IP address and port number to connect to server. can…
Hemanth S R
  • 1,115
  • 2
  • 16
  • 27
3
votes
1 answer

Weird select error in python

Ok, so I have Python 2.5 and Windows XP. I was using select.select with a socket object. I tried it again and again, but whenever I run it, the thread it is in gives me an error like select.error(9, "Bad file descriptor"). The code is something like…
Tom
  • 846
  • 5
  • 18
  • 30
2
votes
1 answer

What part of python.socket could conceivably freeze my script for ever even though timeout is set?

The oauth library (Linked from the Justin.tv Python library page) locks up my Python processes indefinitely at random times. This happens randomly, but OFTEN on one of my servers. I'm positive this is not due to anything in my code, so I'm pasting…
Hubro
  • 56,214
  • 69
  • 228
  • 381
2
votes
0 answers

Error after HDF5 file type transfer via socket: OSError: Unable to open file

I recently wrote a client / server application for transferring files in the hickle (HDF5 based file) format. The export, import and reading with the generated file works as intended. The source code of the client, who sends the file, looks like…
Aiden3301
  • 41
  • 5
2
votes
0 answers

why does my python socket just stop working after it is done chunking and receiving data

basically this code is a server for a project that I am doing the client sends over 600 photos which then I want to be stored in a folder called incoming. first error was me running into my pickle data being Truncated while being sent to my server…
Harvey1G
  • 21
  • 2
1 2
3
33 34