This gist is deprecated and will not be edited in the future. Consider visit ninedraft/python-udp repo. It will not be deleted, however.
Works for python 3.7 and 2.7 for Mac OS and Linux(kernel>=3.9) hosts. If you'ra using linux(kernel<3.9), then use socket.O_REUSEADDR
instead of socket.SO_REUSEPORT
to share (host, port)
between multiple clients and servers.
Tricks and traps:
- Socket portability issues: How do SO_REUSEADDR and SO_REUSEPORT differ?;
- Awesome "Socket Programming HOWTO";
Thank you for offer the code. I was runing the server and client codes on a group of remote machines. I wrote a powershell script to SSH into the server and client machines to start the python codes.
It seems the python codes freezes/hang the SSH every time. May I ask what is causing that and if there is a way around it? Thanks!