Skip to content

Instantly share code, notes, and snippets.

@NimishMishra
Created June 20, 2020 03:27
Show Gist options
  • Save NimishMishra/c2f00a495f3205b55c10cfee977a2bb5 to your computer and use it in GitHub Desktop.
Save NimishMishra/c2f00a495f3205b55c10cfee977a2bb5 to your computer and use it in GitHub Desktop.
def file_handler(target_client, command):
target_client.send(bytes(command, 'utf-8'))
acknowledgement = target_client.recv(BUFFER_SIZE)
if(acknowledgement == b'ACK'):
pass
data_splits = command.split(' ')
mode = data_splits[2]
if(mode == 'r'):
receive_data(target_client)
elif(mode == 'w' or mode == 'a'):
print("enter FILE_UPDATE_QUIT to end data transfer")
while True:
data = str(input("--> "))
target_client.send(bytes(data, 'utf-8'))
if(data == 'FILE_UPDATE_QUIT'):
break
receive_data(target_client)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment