Question: [PYTHON] I'm struggling to create a direct messaging program that includes file transferring. It should have the following: -It must act as either a client
[PYTHON]
I'm struggling to create a direct messaging program that includes file transferring. It should have the following:
-It must act as either a client or server, depending on what arguments in the command line are given when started.
-On top of sending and receiving messages, the program should also be able to transfer files using the binary transfer method, meaning that every byte of a file will be transmitted as is.
-Since the program must also transfer files, it will listen for file requests. Therefore, the program must contain a server to listen for file requests.
-You are allowed to hard-code your program to connect to localhost.
-When the client and server messengers are connected, either end can send messages, whenever, to the other end.
-Messages entered to the program through standard input.
-Right after receiving a message, the program must output the message to standard output.
-A user may request a file from the other end at any time. The user must give the name of the requested file using standard input.
-When the other end receives a file transfer request, it must immediately send all of the bytes in the file to the other end. If the file cannot be found or read, the program may simply ignore the request but it may not terminate.
-When the requesting program receives the file bytes, it must store them in a file with the same name in the local directory.
-Since this program will be menu-driven, the user will terminate the program by using standard input to select to exit, as explained below.
-We terminate the program by first shutting down sending, then closing the socket. Once one end shuts down, the other side will receive a 0 length message, informing it of the shut down. The other side must then shut down immediately.
UI
-A user should interact with the program through standard input. The program must use the following input standards:The program must display a menu of options for the user to choose from. Each option is associated with a single letter, as shown. The options are:
Send a message (m)
Request a file (f)
Exit the program (and disconnect from the other messenger) (x)
-The user may use a lower-case letter.
-To send a message for example, the user must choose the message option by typing the 'm' and pressing Enter. The user then types the message. After the user enters it, the program redisplays the menu for the next user action.
-In order to request a file, the user chooses 'f'. The program must then ask the user to enter the name of the file. After the user enters the request information, the program redisplays the menu for the next user action while the file transfer request is processed in another thread. Hence, the user may be able to continue sending messages and requesting other files while prior file requests are being processed.
-The program will shutdown any connections and terminate as soon as the user enters the 'x' option.
Using the program
-The program must be started with -l, which is the socket its server will listen on. -If the program is going to act as a client, two other options may be used. An -s option specifies the address of the server to connect to, and -p specifies the port number of the server to connect to. If the -s option is not used, then the program connects to localhost. The client and server should both behave the same way, with the same menu and capabilities.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
