Book queries utilizing TCP sockets in Python 3.0
This project consists of four programs: lib_app_bookSrv.py(book server), lib_app_userSrv.py(user server), lib_app_librarian.py(librarian server), and lib_app_client.py(client app). The 4 programs together create a library application that can be supplied with a JSON input file of book names and it will return information about each book.
- Execute run_app.bat
or
- Open 4 command prompts. Start each server with: python3 lib_app_servername.py
- In the last command prompt execute the client application:
- Usage: python3 lib_app_client.py "<inputFile>"
If a port is already in use on your machine, you can modify the port for that program. Each program defines a global variable at the top that specifies the port. If you change the port for a server, be sure you change the port in the client program as well.
- Server: lib_app_librarian.py
- Client: lib_app_client.py
- Server: lib_app_userSrv.py or lib_app_bookSrv.py
- Client: lib_app_librarian.py
- The client server sends a hello message to the librarian server.
- The librarian server sends a welcome message.
- The client sends a BookInquiry to the librarian server.
- The librarian server forwards the query to the book server.
- The book server receives the query, looks up the book, and responds with pertinent info.
- The librarian server forwards the answer to the client.
- If the book Status is borrowed, the client sends a UserInquiry to the librarian server.
- The librarian server forwards the query to the user server.
- The user server receives the query, looks up the user, and responds with pertinent info.
- The librarian server forwards the answer to the client.
- The client prints the details of the book and optional user query to the screen.
- After all queries are made, the client will write them to a file in the current directory named “output.json”.