delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/08/17/10:06:32

X-Spam-Check-By: sourceware.org
Date: Thu, 17 Aug 2006 09:06:36 -0500
From: Brian Ford <Brian DOT Ford AT FlightSafety DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: cygwin AT cygwin DOT com
Subject: RE: Cygwin 1.5.18: Problem using setsockopt() for multicast
In-Reply-To: <00cf01c6c203$da04b5b0$a501a8c0@CAM.ARTIMI.COM>
Message-ID: <Pine.CYG.4.58.0608170853330.2408@PC1163-8460-XP.flightsafety.com>
References: <00cf01c6c203$da04b5b0$a501a8c0 AT CAM DOT ARTIMI DOT COM>
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Thu, 17 Aug 2006, Dave Korn wrote:
> On 17 August 2006 14:45, Brian Ford wrote:
> > On Thu, 17 Aug 2006, Alessandro Saffiotti wrote:
> >>   imreq.imr_interface.s_addr = INADDR_ANY;
> >
> > INADDR_ANY is in host byte order, but you need network order for this
> > call.
>
>   Yeh, that's it!  And don't forget to use left-handed bits - the ordinary
> right-handed ones are no good for INADDR_ANY.  :)

Sorry, not enough coffee yet this morning ;-).  I was up all night with my
two month old daughter.

My point should have been that I use this construct every day in 1.5.18
and 1.5.21 within our application and it works fine.  I saw very few
differences.  Here is my snippet in case I missed something else obvious:

fd = socket(AF_INET, SOCK_DGRAM, 0);

Oh yeah, you must call the setsockopt below after the bind on windows.
Search MSDN for why.

{
    struct ip_mreq mreq;

    mreq.imr_interface.s_addr = htonl(INADDR_ANY);
    mreq.imr_multiaddr.s_addr = inet_addr("224.0.0.1");

    if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
                   sizeof(mreq)) < 0)
        perror("Unable to join 224.0.0.1");
}

-- 
Brian Ford
Lead Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained crew...

.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019