Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > udp multicast server and client

Reply
Thread Tools

udp multicast server and client

 
 
skpopu@gmail.com
Guest
Posts: n/a
 
      04-25-2008
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.
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      04-25-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Antoninus Twink
Guest
Posts: n/a
 
      04-25-2008
On 25 Apr 2008 at 4:30, Richard Heathfield wrote:
> (E-Mail Removed) said:
>> But I facing the problem here recvfrom() got blocked.

>
> 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, ...);
...
}

 
Reply With Quote
 
Sri Harsha Dandibhotla
Guest
Posts: n/a
 
      04-25-2008
On Apr 25, 9:30 am, Richard Heathfield <(E-Mail Removed)> wrote:
> (E-Mail Removed) said:
>
> > I have a two systems and I am able to communicate both systems using
> > udp server and client at both ends

>
> If you have a client-server networking architecture, you'd almost certainly
> be better off with TCP.
>
> <snip>
>
> > 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.

>
> 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.
>
> > But
> > I facing the problem here recvfrom() got blocked.

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


http://beej.us/guide/bgnet/output/ht...et.html#select
hope this is helpful.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDP multicast problem with winsock Gary C C++ 2 05-19-2010 12:18 PM
UDP Multicast Question neilsolent Java 2 01-22-2009 04:49 AM
Python sockets UDP broadcast multicast question?? inorlando Python 3 08-29-2008 05:49 AM
Multicast UDP deamon and VLAN interfaces pietro.cerutti@gmail.com C Programming 7 12-01-2006 05:21 PM
Multicast UDP deamon and VLAN interfaces pietro.cerutti@gmail.com C Programming 0 12-01-2006 08:38 AM



Advertisments