def multi_threaded_client(connection, client_id): connection.send(str.encode('Server is working:')) while True: user_choice = connection.recv(buffer).decode('utf-8') if user_choice < "5": file_name = connection.recv(buffer).decode('utf-8') if user_choice == "4": writeRequest = connection.recv(buffer).decode('utf-8') auditResponse = index.audit_write_request(writeRequest) connection.send(str.encode(auditResponse)) if auditResponse == "passed": writing_text = connection.recv(buffer).decode('utf-8') response = index.main(user_choice, file_name, client_id, writing_text) else: response = "Another Client is accessing the file" else: if user_choice >= "5": file_name = "empty" response = index.main(user_choice, file_name, client_id) if not user_choice or not file_name: break connection.sendall(str.encode(response)) if user_choice == "3": do_close = connection.recv(buffer).decode('utf-8') res = index.close_file(do_close) connection.send(str.encode(res)) connection.close()
# -*- coding: utf-8 -*- import sys from core import index __author__ = "无声" if __name__ == '__main__': #sys.path.append("D:\PythonCode\Demo") index.main()
def start(): index.main()