Python Socket Programming Tutorial

Tech With Tim · 1.2M views · 2020 · 49:43

Open on YouTube

Python, Ruby & scripting languagesNetworking & internet infrastructuretutorial

Why Stack Overflow recommends it

Stack Overflow users link it as a beginner-friendly walkthrough of Python socket programming, and many questions come from people following along and hitting errors like 'Address already in use' or connection timeouts.

Recommended by 4 people across 4 different months, 2020 to 2024.

What it is

A 50-minute Python 3 tutorial by Tech With Tim that builds a socket server and multiple clients using the socket and threading modules. It covers sending messages in both directions and hosting the server locally or across the internet.

What people said

Recommends user12951955 · 2020-08 · Stack Overflow · on “"socket.error: [Errno 48] Address already in use" in Python”

I am following this [this video] tutorial on sockets, and I was doing fine until the teacher ran the program again in the text editor at 34 minutes 44 seconds. On my end, I received an error message saying, socket.error: [Errno 48] Address already in use . I am using a Macbook, and my text editor is Atom. I would appreciate any help I can get with fixing or addressing this error! Traceback Traceback (most recent call last): File "/Users/lyons/Documents/sockets/server.py", line 16, in <module> server.bind(ADDR) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 48] Address already in use [F

Recommends Marcus Cazzola · 2021-01 · Stack Overflow · on “Sending data from raspberry”

You can send data between devices via Socket Communication . You can choose if you want to connect via the local IP address or the public IP address. You send bytes over the network 01001001 01000110. Socket Communication is very standardized so you can send data between different programming languages. If you want to send data over different programming languages, then I recommend sending a JSON file over the Socket communication. Here is a video about Sockets in Python: [this video] NOTE: I had to turn my Network profile to "Private" on my devices to make them discoverable on the network. [LINK]

Recommends Gabe Morris · 2021-08 · Stack Overflow · on “Python Socket does not receive message”

I'm not quite sure where you're getting at. You want to be able to run multiple instances of server.py on the same computer/server? If that's the case, you will have to change the port number because the previous instance of server.py is already using that port. Also, I would like to direct you to this video [this video] which explains socket programming very well. I'm not sure if stack overflow likes people giving recommendations like this or not but oh well.

Recommends liquidRock · 2021-11 · Stack Overflow · on “How to share data between multiple python environments and active scripts controlled by a master script?”

Seems the solution here is to use sockets , create a server , and create clients inside the scripts I need to use. Not sure why my searches weren't bringing up sockets, but it's the solution I needed and doesn't require dependencies. Sockets are built into python so using import sockets can handle most of what I need. On top of that, import threading so multiple threads can be used for clients, and I'm using import system to send system commands. The threads are being setup as daemons to avoid any trouble if a client doesn't disconnect cleanly. This has the benefit of running on a local network but can also be used for more complex system to connect to remote clients and servers. Running loc

Cites koder · 2024-02 · Stack Overflow · on “Timeout error when connecting a client to a server running on a different machine in Python”

I'm new to Networks and socket programming and require help please. I'm following a [this video] and when running the client.py and server.py scripts on my machine, everything works according to the video. But when I try running client.py on different machines (47:30), it doesn't run properly and I get the following error: client.connect(ADDR) TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond This is my server.py: import socket import threading # Server Configuration HEADER = 64 TCP_PORT = 5050 SERVER = socket.gethostbyname(socket.geth