By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

Need advise on sockets

P: n/a
Hi ,

I have a program which has 1 client and 4 servers . Client
sends messages(every second) to all these 4 servers and recieves a
response from these servers . It has load balaning and failover logic
in it .
Now my question is , is it a good practice to connect to these servers
outside the while loop or should I connect these inside the loop(so
that client connect to server everytime a message is being sent ) ..
Wouldn't connecting and closing the socket every second be a load on
the system ?

Thanks !

Sep 15 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ab*****@gmail.com writes:
I have a program which has 1 client and 4 servers . Client
sends messages(every second) to all these 4 servers and recieves a
response from these servers . It has load balaning and failover logic
in it .
Now my question is , is it a good practice to connect to these servers
outside the while loop or should I connect these inside the loop(so
that client connect to server everytime a message is being sent ) ..
Wouldn't connecting and closing the socket every second be a load on
the system ?
This isn't a C question.

Try a newsgroup specific to your system (comp.unix.programmer?).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Sep 15 '06 #2

P: n/a

ab*****@gmail.com wrote:
Hi ,

I have a program which has 1 client and 4 servers . Client
sends messages(every second) to all these 4 servers and recieves a
response from these servers . It has load balaning and failover logic
in it .
Now my question is , is it a good practice to connect to these servers
outside the while loop or should I connect these inside the loop(so
that client connect to server everytime a message is being sent ) ..
Wouldn't connecting and closing the socket every second be a load on
the system ?

Thanks !
connecting and closing the socket every second creates a lot of load on
the system. From the explanation, I see that you are implementing the
heartbeat operations on the servers.

Generally when the client comes up it creates the connections for the
heartbeat to the servers and sends the packets using the timer handler
for every second. The responces are not caught in the timer handler,
but in the main loop where the select/poll is used. Reason, the reply
times may vary and exceed the time length (1 sec).

-kondal

Sep 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.