Skip to content
Snippets Groups Projects
Commit d07fc14d authored by Dixon Tirtayadi's avatar Dixon Tirtayadi
Browse files

Changed communication between paxos nodes to UDP

parent 206ff405
No related branches found
No related tags found
No related merge requests found
......@@ -466,29 +466,15 @@ class BallotValuePair:
# Serialize obj, and send the message.
# This function will not wait for reply (communication between paxos nodes)
def send_msg(obj, dest_addr: Address):
HOST, PORT = dest_addr
data = pickle.dumps(obj)
print(obj, "\n")
print(data, "\n")
de_paxos_req = pickle.loads(data)
print(de_paxos_req, "\n")
#data = " ".join(sys.argv[1:])
#print('data = %s' %data)
# create a TCP socket
# TODO: Between paxos dont use TCP? Use UDP instead? TCP will make it does not drop any packet right?
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
# connect to server
sock.connect((HOST, PORT))
# send data
#sock.sendall(bytes(data + "\n"))
sock.sendall(data)
finally:
# shut down
sock.close()
# create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(data, dest_addr)
sock.close()
if __name__ == "__main__":
HOST, PORT = "localhost", 9999
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment