Commit 6521021b authored by Widener, Patrick's avatar Widener, Patrick
Browse files

commit new files

parent 08525680
Loading
Loading
Loading
Loading

zmq/rcv.py

0 → 100644
+18 −0
Original line number Diff line number Diff line
import zmq

context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5555")

print("ready to receive")

# get metadata first
ms = socket.recv_json()
print("got the json")
sz = socket.recv()
print("got the array")
ary = numpy.frombuffer(memoryview(sz),dtype=md["dtype"])
ary.reshape(md["shape"])

print(f'received {ary.len()} elements')

zmq/reader.py

0 → 100644
+19 −0
Original line number Diff line number Diff line
import numpy as np
import zmq


ary = np.load("../data/p_322_data_np_res_8.npy")
print('array contains {} elements'.format(ary.size))

# set up metadata for numpy array reconstruction
md = dict(dtype=str(ary.dtype),shape=ary.shape)

context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")

# send metadata first
socket.send_json((md),zmq.SNDMORE)
socket.send(ary)

print("sent all elements")