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

Is there a way to select the correct network interface using netifaces or socket?

Before using a scraper, I have a piece of code that checks whether a VPN is connected, and prompts to connect if it isn't. I was using the socket module to check for this, but this never returns the IP addresses associated with the VPN. I'm now…
MKJ
  • 120
  • 8
2
votes
1 answer

Looking up hostnames from Docker container

I'm currently trying to get lookup hostnames from inside a docker container using python. My example script is exceedingly simple, so here we go: import sockets print(socket.gethostbyaddr('8.8.8.8')) It works fine from my Windows machine, and it…
Lucy The Brazen
  • 135
  • 1
  • 9
2
votes
1 answer

Python sockets and requests

I'm a beginner in python and I'd like to know what the difference between socket and requests modules in python is. I'm sorry if this question format is bad, if this may be due to the fact that I do not know exactly how different protocols of…
2
votes
0 answers

How to connect two remote computers with python-socket so that they can send and receive data when internet is available?

I am using Mobile Hotspot with configurations Security:WPA2-Personal and AP Band:2.4GHz-band. Server code: import socket s = socket.socket() print ("Socket successfully created") s.bind(("0.0.0.0", 9999)) # xxxx also does not work # xxx=external ip…
Curious Learner
  • 1,182
  • 1
  • 4
  • 17
2
votes
1 answer

Unable to transfer file using Sockets on different computers

I recently wrote a code for a file transfer in Python. Sockets connect fine when I connect them from different terminals on the same system. But the same doesn't seem to work when I connect them from different computers which are connected over the…
2
votes
1 answer

I need client side to write to the server side

I'm trying to make the clients be able to send messages to the server, right now clients can only send messages to each other, I have added the line where datafromclient but it only receives the first input by the client, after that only the clients…
Elfo
  • 21
  • 2
2
votes
1 answer

How to get subject dn with python

What would be a nice way to get SSL's Subject DN with python ? This includes things like: Country name State name Locality name Org name Common name
Martin Gergov
  • 1,556
  • 4
  • 20
  • 29
2
votes
1 answer

Trying to make a Server application with socket and tkinter

I am trying to make this Socket & tkinter server app the point in Short form is this is a tk window that basically makes a socket server with some Buttons and some Entrys. And the thing is the server maker is not working. this is what mean the…
Pymain3664
  • 53
  • 1
  • 8
2
votes
1 answer

python receiving data from a friend

I'm new to this whole shazam and I'm a little confused. I want to have a server receive data on my computer, and a friend send data on his own computer. The code for my server is as follows: import socket HOST = 'HOST' PORT = PORT with…
terrabyte
  • 307
  • 1
  • 3
  • 12
2
votes
0 answers

Can't receive multicast packets although I can see the stream via tcpdump

In my Linux, I have an interface eth5 with IP 10.46.55.106. I see the multicast stream on eth5: $ tcpdump -i eth5 host 233.113.216.61 and port 21001 11:18:19.416631 IP 194.0.142.188.48253 > 233.113.216.61.21001: UDP, length 20 11:18:19.450577…
xyzt
  • 1,201
  • 4
  • 18
  • 44
2
votes
3 answers

How to use a socket created by root with a normal user

So I have this server: import socket sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.bind('/tmp/sock.sock') sock.listen(1) while True: conn, ca = sock.accept() print(conn.recv(1024)) And this client: import socket sock =…
klutt
  • 30,332
  • 17
  • 55
  • 95
2
votes
1 answer

My client program is accepting only one byte from the server using python socket api

I'm trying to get the machine data from a CNC HAAS controller. It has a built-in software called MDC, which acts as a server. I need to write a client program to send a request to the MDC's IP and port number. when I send a request and receive it…
2
votes
0 answers

Sending audio files every 60s from Android to python server through socket

I get stuck on sending an audio file, recorded, from an android app, every 60s on a Python server through socket. I succeed in sending a file from a python client to a python server. If a send a file of 60s from a python client, the python server…
2
votes
1 answer

How to write an infinite loop for receiving UDP data?

I'm trying to make an app that receives UDP data and shows the data in a list view using python (PyQt5). When I start the receiver, the app gets stuck and does not respond. How can I fix this? See code below. import sys import os import socket from…
2
votes
2 answers

Only running Pygame display code once data revieved from python socket connection

I want to write a pygame programme where I am receiving data from a Raspberry Pi over a socket connection. However I only want the Pygame code to run once the string has arrived. This involves the code waiting for some time, then when a string is…
user9015687
  • 37
  • 2
  • 5