I'm using ARM - 9 Series with running linux kernel version 2.4.x. I have setup a server application for accepting TCP/IP requests and it works fine. Now what I want t know is that what should be the generic design for this server? My existing design is something like: SERVER:1) Creating a socket for incoming. 2) Bind it statically. 3) Waiting for client 4) Get the request from client [ Receive ] 5) Do appropriate actions 6) Send result back to client [ Send ] 7) Close the client
Step 3 to 7 are in wild loop (while(1)) so every time I receive a request I use to create a new connection and close it as soon as I'm done with step 6.
Following is the abstraction of my client. CLIENT: Say there are tow actions performed by client.1) Start getting data from server. 2) Stop getting data from server.
I'm doing the above in following manner:1) Request to connect 2) Send Query to server 3) Receive results from server 4) As server always close the connection so I do the same in client too. Yeah closing the connection.
Step 1 to 4 are performed in wild loop too until there is a Stop reading action.
Design constraint: As this server is for embedded system so along the memory constrains I do have to make it human interactive less.
Question: a) How good and efficient it is to accept and close the collection every time? Where as my client is suppose to get the data from server in continuous manner. b) I have observed on Fedora core that some times I couldn't get the required port but frankly havn't observed this behavior in ARM. Let say it happens on ARM too so what to do then? As there will be no human interaction to kill the running process and start it again;-) c) Shall I keep the connection alive unless timeout or close action from client ?
Thanks for your suggestions. kill -9 (int)ali