udp multicast server and client

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • skpopu@gmail.com

    udp multicast server and client

    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.
  • Richard Heathfield

    #2
    Re: udp multicast server and client

    skpopu@gmail.co m 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. You are
    more likely to find network programming expertise somewhere like
    comp.unix.progr ammer - so I recommend you try that group for future
    questions (or even for this one, if select() doesn't sort you out).
    I need any one of ur
    help. Please Note that I am using only UDP sock streams not TCP.
    That's impossible. UDP doesn't do streams. It's a datagram protocol. Fire
    and forget.

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Comment

    • Ian Collins

      #3
      Re: udp multicast server and client

      skpopu@gmail.co m 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.progr ammer (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.

      Comment

      • Antoninus Twink

        #4
        Re: udp multicast server and client

        On 25 Apr 2008 at 4:30, Richard Heathfield wrote:
        skpopu@gmail.co m 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, ...);
        ...
        }

        Comment

        • Sri Harsha Dandibhotla

          #5
          Re: udp multicast server and client

          On Apr 25, 9:30 am, Richard Heathfield <r...@see.sig.i nvalidwrote:
          skp...@gmail.co m 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.

          hope this is helpful.

          Comment

          Working...