• C

client-server

Hi experts,
I've a simple client and server in C on unix platform. The server displays the date in 'mm/dd/yy' OR 'dd/mm/yy' format depending upon the requested format by client.
It's running absolutly fine, but it's for single client. Now, I'm trying to implement it for multiple clients using select(), it's going fine, but is it possible for server to remember the choice for every client?
I mean can the server remember which client requests date in which format?

Thanks in advance
tech1guyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
All you need to do is to associate the clients with their 'context data'. I'd use a struct for that, e.g.

struct client {

socket s;
unsinged int format;
//...
};
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tech1guyAuthor Commented:
could you please explain that in some detail as I'm NOT a expert in client-server programming.
0
jkrCommented:
Well, your problem is that you some sort of connection set up (I was assuming a socket in the above) and need to associate data (settings in your case) with that connection. So you have to somehow 'bundle' that information, and that's where structs come in handy.
0
Firewall Management 201 with Professor Wool

In this whiteboard video, Professor Wool highlights the challenges, benefits and trade-offs of utilizing zero-touch automation for security policy change management. Watch and Learn!

tech1guyAuthor Commented:
I'm not closing connection after each client is served. I'm using Select()method instead of Fork. Will your technique work with my scenario?
0
jkrCommented:
Yes, you only need to store the data for each connection seperately, regardless of how you maintain the communication itself.
0
tech1guyAuthor Commented:
thanks! it helps
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.