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
pull/1/head
Tatsuhiro Tsujikawa 2010-03-09 14:19:25 +00:00
parent 22308b3ac9
commit 91b7b721ea
3 changed files with 16 additions and 0 deletions

View File

@ -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.

View File

@ -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,

View File

@ -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,