udp multicast server and client

S

skpopu

I have a two systems and I am able to communicate both systems using
udp server and client at both ends but I need to make one system as
concurrent server and now I would like to add one more system into the
group and now I would like to multicast the message from My main
server to the new joined system and now I should be able to send and
recieve from both the other systems to the main server.
Exactly what I have with me is : Two systems having udp server and
client programs running in each of the systems and they are
communicating well.
Now what I need is I am adding one more system to my network and I
should be able to serve the other system also from One of this
systems.For this I have made One thread as listener thread and every
time a new client comes for service it is seperated as new thread. But
I facing the problem here recvfrom() got blocked. I need any one of ur
help. Please Note that I am using only UDP sock streams not TCP.Thanks
for helping me.
 
I

Ian Collins

Now what I need is I am adding one more system to my network and I
should be able to serve the other system also from One of this
systems.For this I have made One thread as listener thread and every
time a new client comes for service it is seperated as new thread. But
I facing the problem here recvfrom() got blocked. I need any one of ur
help. Please Note that I am using only UDP sock streams not TCP.Thanks
for helping me.

You probably should ask on comp.unix.programmer (or a winsock
equivalent). As Richard just said, your situation is not uncommon,
similar question often pop up on c.u.p.

As an aside, using blocking sockets with threads is common. Also you
can't reliably stream over UDP without a using higher level protocol to
do the work usually done by TCP.
 
A

Antoninus Twink

(e-mail address removed) said:

Look long and hard at select().

Good advice. Perhaps a short piece of example code will be helpful to
the OP.


#include <sys/select.h>

....

/* set up your socket with file descriptor fd */

....

int r;
fd_set rfds;
struct timeval tv;

FD_ZERO(&rfds);
FD_SET(fd, &rfds);

tv.tv_sec = 30;
tv.tv_usec = 0; /* timeout after 30 secs plus 0 ms */

r=select(fd+1, &rfds, NULL, NULL, &tv);

if (r<0) {
/* deal with error */
} else if (r==0) {
/* deal with timeout */
} else {
recvfrom(fd, ...);
...
}
 
S

Sri Harsha Dandibhotla

(e-mail address removed) said:


If you have a client-server networking architecture, you'd almost certainly
be better off with TCP.



That is a very common design, but not one that I consider to be very wise.
When there are many clients, it over-uses thread resources, and under-uses
everything else. Having said that, it sounds like you only want to have a
very, very tiny network, so perhaps in your case it doesn't matter.


Look long and hard at select(), which is not a standard C function.

http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html#select
hope this is helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top