• Eric Orth's avatar
    Better setup for non-windows multicast sockets. · 7141dbc7
    Eric Orth authored
    In addition to SO_REUSEADDR, that we were setting before, via
    AllowAddressReuse(), for sockets for use with multicast, now also set
    SO_REUSEPORT whenever that option is defined. On some non-Windows
    platforms, this is needed for multicast messages to be received by all
    sockets listening for them. This option is only set in a new
    AllowAddressSharingForMulticast() method as the SO_REUSEADDR and
    AllowAddressReuse() have other non-multicast uses where SO_REUSEPORT
    would not be appropriate.
    
    Also, for non-Windows platforms, bind the multicast sockets to the
    multicast group address rather than to a wildcard. This will make us
    more likely to only get messages from the relevant multicast group as
    some platforms will otherwise give the socket any multicast messages
    from groups joined by any sockets in the system. No change on Windows
    where binding to a multicast group is not allowed.
    
    TBR=thestig@chromium.org
    
    Change-Id: I24d9d4a0d85134074b2deb14914a41109d7f724a
    Bug: 899310
    Reviewed-on: https://chromium-review.googlesource.com/c/1298298
    Commit-Queue: Eric Orth <ericorth@chromium.org>
    Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
    Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
    Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#603180}
    7141dbc7
udp_socket_unittest.cc 45.7 KB