Awesome Open Source
Awesome Open Source

Python C sockets

Actions Status

Multi-platform (BSD, Linux, Mac, Windows Subsystem for Linux 2) demo of IPv6 UDP datagram on C and Python. Maximum speed is only limited by interface speed--approaching 1Gbps on my laptop. This is simple yet performant code.

The server (C-code) goes on the device, the Python code runs on the laptop.

The data flow rate on localhost ::1 with gigabit network card is 1 Gbps.

NOTE: The multicast programs are for learning purposes only. In real networks, multicast use could overwhelm the network with traffic. Use contemporary point-point performant methods like websockets instead.


We are beginning to implement these examples via C++17 header-only library Kissnet. This solves the issues of platform independence.

Until the kissnet transition is complete, Windows users should use WSL 2 as WSL 1 doesn't have a fully functional network stack.


cmake -B build
cmake --build build

ctest --test-dir build -V

Unicast examples

Kissnet loopback



  1. open terminal:

  2. open another terminal:

    nc -u ::1 2000

You will see text you type echoed back to you when you press Return key

Streaming float array

This demo sends 8192 byte float32 arrays, by first sending an int telling the length of the upcoming float32 array

  1. Open terminal:
  2. Open another terminal:

I see ~70 microseconds cycle time on my laptop --> 8192 / 70e-6 * 8 ~ 936 Mbps

Write streaming data to HDF5

HDF5 files can be as large as your hard drive, and these tests run extremely fast, so I disabled the unlimited writing so that you didn't write a huge file.


Run the unicast_tx and in the second terminal window run:

python -o test.h5


Run the unicast_tx and in the second terminal window run:


IPv6 Multicast examples

  1. open a terminal:
  2. open a second terminal:

IPv4 multicast

In general IPv6 should be used instead.

  1. open a terminal:

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (863,999
C (189,936
Terminal (18,059
Udp (5,565
Laptop (2,386
Ipv6 (1,140
Hdf5 (198