Category: Python

Using struct module to send/receive floats over TCP socket with Python

Server This sends 10 floats at a time, on a loop. The transmit data type is determined by the’=%sf’ % payload.sizeformat string passed tostruct.pack. import socket from struct import * import numpy as np #number of floats we are sending payload_size = 10 payload = np.linspace(0, 10, payload_size) print(‘Sending {}’.format(payload)) #pack the floats as bytes…

Read the full article