Re: [gnet] Multicasting - UDP



Large packets should be ok on a local network.  If parts of the cluster
are on different networks, then you may want to break the membership
list into several packets.

One way of handling the unknown packet size is to use recvfrom() with
the MSG_PEEK flag.  If the bytes read are equal to the buffer size, then
make the buffer larger and try again.  

There's probably a better way of doing this...   It looks like recvmsg()
will tell you if the packet has been truncated.

There may be a way to get the exact packet size - check Steven's UNP.

David



On Sun, 2003-06-01 at 16:38, Nelio Pereira wrote:
> Hi David.
> 
> Let me tell you more about my application. I'm
> developing a cluster membership service, i.e, a
> service that runs on every node of a cluster to keep
> each one of them with the same view of the members of
> this cluster.
> 
> To send asynchronous messages to group members, I
> decided to use multicast messages. I don't know too
> much about them, so I don't know exactly what are
> their limitations. I had already looked at
> recv/recvfrom, but there's no way to read more data
> than what my buffer can receive. 
> 
> The messages that I exchange among the nodes will be
> larger as the cluster grows. That's why I don't want
> to be limited on the message size. 
> 
> Given this scenario, do you have any sugestion/warning
> ? I'd appreciate any comments.
> 
> Cheers,
> 
> Nelio 
> 
> 
>  --- "David A. Helder" <dhelder gizmolabs org>
> escreveu: > 
> > Nelio,
> > 
> > Use recv() or recvfrom().  It will tell you the
> > buffer length, so you
> > don't need the \0.
> > 
> > The buffer should be large enough to fit the largest
> > possible packet for
> > your application.  Typically you want to keed it
> > under ~1500 bytes,
> > since that's the maximum packet size for ethernet. 
> > If it's above that,
> > the packet will be fragmented, which increases the
> > chance the whole
> > packet will be dropped.
> > 
> > David
> > 
> > 
> > On Fri, 2003-05-30 at 22:30, Nelio Pereira wrote:
> > > I want to send a piece of information over
> > multicast,
> > > and this information doesn't have a pre-determined
> > > size. That is, its length will vary according to
> > the
> > > the moment. To determine that the buffer is over,
> > I'm
> > > attaching a '\0' at its end. My question: how can
> > I
> > > receive this kind of information over UDP sockets?
> > If
> > > I have a receiver buffer large enough to
> > accomodate my
> > > message, everything is fine; if my receiver buffer
> > is
> > > smaller than the information being sent, I cannot
> > make
> > > two consective reads on the UDP socket to get the
> > rest
> > > of the message.
> > > 
> > > Does anyone can help me with this issue?
> > 
> > 
> > 
> > -- 
> > David Helder - dhelder gizmolabs org -
> > http://www.gizmolabs.org/~dhelder
> >  
> 
> =====
> +------------------------------------------------------------------------+
>                        http://www.ime.usp.br/~nelio
> 
> _______________________________________________________________________
> Yahoo! Mail
> Mais espaço, mais segurança e gratuito: caixa postal de 6MB, antivírus, proteção contra spam.
> http://br.mail.yahoo.com/
-- 
David Helder - dhelder gizmolabs org - http://www.gizmolabs.org/~dhelder




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]