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

sending video stream from server to client using socket programming in python

I am trying to send video stream from server to client using python sockets but facing errors. Here is my server side and client side code.There is some problem with sending frame from server to client , Here is my SERVER SIDE code …
user3646858
  • 137
  • 1
  • 2
  • 12
0
votes
1 answer

Why do I have to restart the tcp_server program once it receives the data?

I'm using a simple tcp_server in python. Here is the code:- import socket TCP_IP = '127.0.0.1' TCP_PORT = 5005 BUFFER_SIZE = 1024 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((TCP_IP, TCP_PORT)) s.listen(1) conn, addr =…
Praful Bagai
  • 16,684
  • 50
  • 136
  • 267
0
votes
1 answer

back-and-forth unix domain sockets lock

I am writing two programs one in c++ and the other in Python to communicate with each other using unix domain sockets. What I am trying to do is have c++ code send a number to the python code, which in turn send another number back to c++. This goes…
0
votes
1 answer

Python Socket - Use Client in Seperate Function

I am developing a basic server login system which I can use for almost anything, the problem is when you define clients like for example: client, address = socket.accept() data = client.recv(1024) print(data) So you can easily do this but what I…
Dan Alexander
  • 2,004
  • 6
  • 24
  • 34
0
votes
2 answers

Socket Blocked when Reading Huge Content Length in Python URLLIB2

I'm using Python to consume a web service that returns a JSON response. When the content length of the response is not that big, everything goes perfectly. It appears that the issue comes in front when the content length of the response is extremely…
Luis Crespo
  • 1,610
  • 1
  • 20
  • 33
0
votes
1 answer

Qt Write to UDP Socket on Linux Machine and Windows Read from Socket with Python

=========== UPDATE: =========== I am now using the broadcast ip 10.6.0.3 and a higher port, 57890. I can see the traffic in Windows Network Monitor but still cannot get Python to read it. ============================== I have a linux machine writing…
PhilBot
  • 748
  • 18
  • 85
  • 173
0
votes
1 answer

How to create a class with a socket member

I created the following class that I want to have a socket member within it and then want to use member functions to connect, close, send, and receive. class Connection: Kon = "" SSLx = "" def Close(self): try: self.Kon.close() …
BMC
  • 591
  • 3
  • 7
  • 22
0
votes
1 answer

Socket use in python

I want to create a chat program between two machines. I am using machine one which has the IP address 192.168.0.5, I can successfully send a message to machine two 192.168.0.2, and then send a message in response from machine two, to machine…
Wesley Wood
  • 7
  • 3
  • 5
0
votes
1 answer

Send login packet to Minecraft Server

Is there a way to send a login packet to Minecraft server from Python? Here is what I have right now: import socket client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) addr = ("localhost",…
JadedTuna
  • 1,783
  • 2
  • 18
  • 32
0
votes
1 answer

faster or batch alternative to python's socket.gethostbyaddr()?

Is there a faster or batch alternative to socket.gethostbyaddr() for the purpose of determining the host, given an IP address? Thank you.
Lamps1829
  • 2,231
  • 3
  • 24
  • 32
0
votes
2 answers

Flask read socket

I have created a web service using flask. Now, it turns out that I have to support some socket connections in the same app. I tried using a specific url and then read from request.stream where request is from flask import request The data is…
kechap
  • 2,077
  • 6
  • 28
  • 50
0
votes
1 answer

multithreading for python socket

I am trying to make my own pyloris script, but I am not getting any connections; here is what I have: #!/usr/bin/python import sys,socket import threading from time import sleep s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) HOST =…
D4zk1tty
  • 123
  • 1
  • 3
  • 15
0
votes
1 answer

Multicast with select

My server work fine with my select function : readable, writable, exceptional = select.select(inputs, outputs, timeout) Here is the code for writable loop : for s in writable: try: next_msg = message_queues[s].get_nowait() except…
Defcode
  • 3
  • 3
0
votes
1 answer

TCP message from gps tracker

I'm writing a simple python script to catch messages from gps trackers and write messages to server's db. # -*- coding: utf-8 -*- import socket, string import MySQLdb def write_message(x): db = MySQLdb.connect(host="localhost", user="root",…
Павел Тявин
  • 2,529
  • 4
  • 25
  • 32
-1
votes
0 answers

ERROR Audio dont want to play at the client side but rather played at the server side and vice versa

I want to try make an application where server and client will stream both audio and video to each other. At first when i try to run both server and client at one laptop it seems that it work fine but when i tried to run server and client at the…