/*! Scans an interface and enumerates all baos devices. It sends a search request as outlined in the BAOS 1.2 protocol documentation and waits for the responses. There are lots of magic numbers here and hard-coded offsets... See the spec for more information on what is happening here... We implement a receive timeout, and keep receiving until this timeout elapses. If this timeout is too fast, increase it to 500 or 1000 for example. */ void BaosIpEnumerator::scanInterface(const NetworkInterface& networkInterface) { poco_information(LOGGER(), format("Search devices on interface: %s (%s)", networkInterface.displayName(), networkInterface.address().toString())); try { // initialize socket MulticastSocket socket; socket.bind(SocketAddress(networkInterface.address(), 0)); socket.setTimeToLive(DefaultMulticastTTL); // builds and sends a SEARCH_REQUEST to the socket sendSearchRequestFrame(socket); // wait for SEARCH_RESPONSES and collect it waitForSearchResponseFrames(socket); } catch (Poco::Exception& e) { poco_warning(LOGGER(), format("... search failed with error: %s", e.displayText())); } }
bool HTTPMUSocket::send(const std::string &msg, const std::string &bindAddr, int bindPort) { MulticastSocket msock; if ((0 < bindAddr.length()) && (0 < bindPort)) msock.bind(bindPort, bindAddr); DatagramPacket dgmPacket(msg, &m_ssdpMultiGroup); // Thnaks for Tho Beisch (11/09/04) msock.setTimeToLive(4); msock.send(&dgmPacket); return true; }