change for udp implementation

This commit is contained in:
Daniel 2021-04-19 15:14:44 +01:00
parent 945a496016
commit 7ef95f62fe
2 changed files with 9 additions and 9 deletions

View File

@ -23,12 +23,12 @@ s.bind((SERVER_HOST, SERVER_PORT))
# enabling our server to accept connections
# 5 here is the number of unaccepted connections that
# the system will allow before refusing new connections
s.listen(5)
# s.listen(5)
print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}")
# accept connection if there is any
client_socket, address = s.accept()
# client_socket, address = s.accept()
# if below code is executed, that means the sender is connected
print(f"[+] {address} is connected.")
# print(f"[+] {address} is connected.")
def pressRrelease_char(char, which):
@ -39,7 +39,7 @@ def pressRrelease_char(char, which):
while True:
# read 1024 bytes from the socket (receive)
bytes_read = client_socket.recv(BUFFER_SIZE)
bytes_read = s.recv(BUFFER_SIZE)
if not bytes_read:
# nothing is received
# file transmitting is done take another time

View File

@ -16,15 +16,15 @@ s.bind((SERVER_HOST, SERVER_PORT))
# enabling our server to accept connections
# 5 here is the number of unaccepted connections that
# the system will allow before refusing new connections
s.listen(5)
# s.listen(5)
print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}")
# accept connection if there is any
client_socket, address = s.accept()
# client_socket, address = s.accept()
# if below code is executed, that means the sender is connected
print(f"[+] {address} is connected.")
# print(f"[+] {address} is connected.")
# receive the file infos
# receive using client socket, not server socket
received = client_socket.recv(BUFFER_SIZE).decode()
received = s.recv(BUFFER_SIZE).decode()
filename, filesize = received.split(SEPARATOR)
# remove absolute path if there is
#filename = os.path.basename(filename)
@ -37,7 +37,7 @@ filesize = int(filesize)
while True:
# read 1024 bytes from the socket (receive)
bytes_read = client_socket.recv(BUFFER_SIZE)
bytes_read = s.recv(BUFFER_SIZE)
if not bytes_read:
# nothing is received
# file transmitting is done take another time