Simple client/server application
Posted on 2006-05-08
I need help on making my application. It is a client/server application. It is quite simple, but I am not sure how it should be done.
The requirements are like this :
1. SERVER will wait for a client connection.
2. CLIENT will connect to the server and send a command "PROCESS_THIS".
3. SERVER will respond to the client by sending text "PLEASE_WAIT, YOUR JOB_ID=<number>".
4. Then the CLIENT should WAIT until the SERVER has finished the job. The waiting time could take between 15 minutes up to 1 hour.
5. When the SERVER has finished, it will inform the CLIENT by sending text "JOB_ID=<number> IS DONE".
6. Then the CLIENT will close the socket connection.
I am thinking of using the Indy components, but I cant figure out the step 4, the CLIENT waiting process. Because from all the examples in Indy, client server application is very straight forward :
1. SERVER is waiting
2. CLIENT is connecting and sending command
3. SERVER is sending a response
4. CLIENT close the connection
In my situation, the CLIENT waiting is required because it should wait the SERVER to finish the job.
To make it more complex, while processing a job from a CLIENT, the SERVER can receive another job from OTHER CLIENT.
Could you please help? Which one is more suitable, UDP or TCP?
Example of codes are really appreciated.