A - U23cs068 - Suyash - Yadav - Lab Assignment 4
A - U23cs068 - Suyash - Yadav - Lab Assignment 4
SERVER SIDE :
import socket
# open a new file and create the file called recieved_suyash ( this shows
we received on the server )
with open(f"recieve_{filename}", "wb") as file:
while True:
data, addr = server_socket.recvfrom(BUFFER_SIZE)
if data == b"END": # End of file signal
break
file.write(data)
server_socket.sendto(b"ACK", addr) # Sending acknowledgment on
receiving the file
CLIENT SIDE:
import socket
filename = "suyash.txt"
client_socket.sendto(filename.encode(), server_address)
# confirmation
client_socket.sendto(b"END", server_address)
print("File sent successfully.")
client_socket.close()