What steps will reproduce the problem?
1. run two instances on linux, listening to the same addr+port
2. the 2nd instance does not work:
mnc: Could not bind to group-id
mnc: Can not listen for multicast packets.
This is because the socket doesn't have the socket option SO_REUSEADDR
enabled, and so the bind fails.
Version: checkout from SVN:
mnc-read-only]$ svn info
Path: .
URL: http://mnc.googlecode.com/svn/trunk
Repository Root: http://mnc.googlecode.com/svn
Repository UUID: 4137c4bc-9619-0410-8247-ed9ae3643143
Revision: 13
Node Kind: directory
Schedule: normal
Last Changed Author: colmmacc
Last Changed Rev: 13
Last Changed Date: 2007-05-19 08:33:56 -0500 (Sat, 19 May 2007)
Running on redhat linux
Please provide any additional information below.
I hacked a solution (good enough for my needs) with this patch:
mnc-read-only]$ svn diff
Index: mnc_multicast.c
===================================================================
--- mnc_multicast.c (revision 13)
+++ mnc_multicast.c (working copy)
@@ -274,6 +274,15 @@
size_t rcvbuf;
#ifndef WINDOWS
+
+ int enabled = 1;
+ if (setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, &enabled,
+ sizeof(enabled)) < 0)
+ {
+ mnc_warning("Could not set socket-option REUSEADDR: %s\n",
+ strerror(errno));
+ }
+
/* bind to the group address before anything */
if (bind(socket, group->ai_addr, group->ai_addrlen) != 0)
{
Original issue reported on code.google.com by cuz...@gmail.com on 22 Apr 2010 at 8:27
Original issue reported on code.google.com by
cuz...@gmail.com
on 22 Apr 2010 at 8:27