Ver código fonte

2010-03-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	For LPD sockets, bind IN_ADDRANY because binding multicast address
	fails under Windows.
	* src/LpdMessageReceiver.cc
	* test/LpdMessageDispatcherTest.cc
Tatsuhiro Tsujikawa 15 anos atrás
pai
commit
91b7b721ea
3 arquivos alterados com 16 adições e 0 exclusões
  1. 7 0
      ChangeLog
  2. 5 0
      src/LpdMessageReceiver.cc
  3. 4 0
      test/LpdMessageDispatcherTest.cc

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+2010-03-09  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	For LPD sockets, bind IN_ADDRANY because binding multicast address
+	fails under Windows.
+	* src/LpdMessageReceiver.cc
+	* test/LpdMessageDispatcherTest.cc
+
 2010-03-09  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Fixed the bug that error message is not propagated to Exception.

+ 5 - 0
src/LpdMessageReceiver.cc

@@ -52,7 +52,12 @@ bool LpdMessageReceiver::init(const std::string& localAddr)
 {
   try {
     _socket.reset(new SocketCore(SOCK_DGRAM));
+#ifdef __MINGW32__
+    // Binding multicast address fails under Windows.
+    _socket->bindWithFamily(_multicastPort, AF_INET);
+#else // !__MINGW32__
     _socket->bind(_multicastAddress, _multicastPort);
+#endif // !__MINGW32__
     if(_logger->debug()) {
       _logger->debug("Joining multicast group. %s:%u, localAddr=%s",
                      _multicastAddress.c_str(), _multicastPort,

+ 4 - 0
test/LpdMessageDispatcherTest.cc

@@ -43,7 +43,11 @@ void LpdMessageDispatcherTest::testCreateLpdRequest()
 void LpdMessageDispatcherTest::testSendMessage()
 {
   SharedHandle<SocketCore> recvsock(new SocketCore(SOCK_DGRAM));
+#ifdef __MINGW32__
+  recvsock->bindWithFamily(LPD_MULTICAST_PORT, AF_INET);
+#else // !__MINGW32__
   recvsock->bind(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT);
+#endif // !__MINGW32__
   recvsock->joinMulticastGroup(LPD_MULTICAST_ADDR, LPD_MULTICAST_PORT, "");
   
   LpdMessageDispatcher d("cd41c7fdddfd034a15a04d7ff881216e01c4ceaf", 6000,