This code tests the ability to add up 4 unsigned 32-bit integers. Hint: Keep in mind that it wraps. (link)
This ones a bit more complicated than net0 and net1, but overall very similar.
Your job is to read 4 32-bit little-endian integers, add them up, and send them back.
I wrote a quick python script that does it:
HOST = "127.0.0.1"
PORT = 2997
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
total = 0
for i in range(4):
val = int(struct.unpack("I", s.recv(4)))
total += val
total &= 0xffffffff
to_send = struct.pack("I", total) + "\n"
print "sending:", to_send
print "response:", s.recv(1024)
Running it gives the following output:
user@protostar:/opt/protostar/bin$ python /tmp/net2.py
response: you added them correctly