python - File Transfer using TCP - Server side -
i trying send file server client server not sending file. can help me out ?
while 1: # server waits incoming requests; new socket created on homecoming connection_client_socket, addr = connection_server_socket.accept() # read name of file sent client file_name_client = connection_client_socket.recv(1024) file_name = file_name_client.decode('utf-8') i hope programme works till line properly.
file_name_to_look_for = file_name file_search_status = 0 root, dirs, files in os.walk('c:\\users\\welcome\\desktop\\arun\\'): if file_name_to_look_for in files: file_search_status = 1 print("file found @ : %s" % join(root, file_name_to_look_for)) break if file_search_status == 0: ## # file requested client not found on server ## capitalized_file_name_client = "file not found".encode() connection_client_socket.send(capitalized_file_name_client) else: # file has been found on server # send notification client stating file transfer begins capitalized_file_name_client = "file found".encode() connection_client_socket.send(capitalized_file_name_client) begin_file_transfer(file_name,connection_client_socket) # close tcp connection # welcoming socket continues connection_client_socket.close() python
No comments:
Post a Comment