This is a multi-process server whose primary purpose is to respond to queries sent by the user from an android application. It send the bus or the bus stop information to the user based on the request. It also sends data regarding the position of the bus .
This server has access to the database which is created and updates by the pseudo server. This server is ideally hosted on the same computer as the pseudo server. It spawns a new process to respond to the request from the user since multiple users might want to access the database at the same time. As soon as the request is processed, the process is killed.
The server is listening continuously on a port dedicated for this purpose.
The user application sends a code using the TCP/IP protocol because data loss cannot be tolerated. Each request is sent as a code which are shown below:
Code Purpose
21 Get bus 21 information
22 Get bus 22 information
33 Get bus stop 33 information
34 Get bus stop 34 information
100 Get bus 21 current position
101 Get bus 22 current position
The server sends a response by collecting data from the appropriate table and appending the strings to form 1 38 byte string with a ' $ 'as a last character to indicate end of string to the receiving android application.
Advantage of having 2 servers:
The data logging part is separated from the data retrieval part and hence the backend is more modular and reliable. One central server can be complex to manage as it might be difficult to handle data sent bus stops and user applications all on one port.
No comments:
Post a Comment