net2.py

#!/usr/bin/env python

import socket
import struct

IP="172.16.184.152"
PORT=2997


# Create client socket and connect to the IP/PORT
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s1.connect((IP, PORT))

# Receive first number from the server
data = s1.recv(2048)
number1 = struct.unpack("<I", data)[0]

data = s1.recv(2048)
number2 = struct.unpack("<I", data)[0]

data = s1.recv(2048)
number3 = struct.unpack("<I", data)[0]

data = s1.recv(2048)
number4 = struct.unpack("<I", data)[0]

sum = number1 + number2 + number3 + number4
while sum >= 4294967296:
	sum = sum - 4294967296

print "Received numbers: %d, %d, %d, %d" % (number1, number2, number3, number4)
print "Sum: %d" % (sum)

number_le = struct.pack("<I", sum)

# Send data to the server
s1.send(number_le)

# Receive data from the server
data = s1.recv(2048)
print data

# Close the socket
s1.close()

 

screen-shot-2016-12-01-at-21-31-18