コード例 #1
0
ファイル: UDPSocket.cpp プロジェクト: SJasoria/gecko-dev
nsresult
UDPSocket::DoPendingMcastCommand()
{
  MOZ_ASSERT(mReadyState == SocketReadyState::Open, "Multicast command can only be executed after socket opened");

  for (uint32_t i = 0; i < mPendingMcastCommands.Length(); ++i) {
    MulticastCommand& command = mPendingMcastCommands[i];
    ErrorResult rv;

    switch (command.mCommand) {
      case MulticastCommand::Join: {
        JoinMulticastGroup(command.mAddress, rv);
        break;
      }
      case MulticastCommand::Leave: {
        LeaveMulticastGroup(command.mAddress, rv);
        break;
      }
    }

    if (NS_WARN_IF(rv.Failed())) {
      return rv.StealNSResult();
    }
  }

  mPendingMcastCommands.Clear();
  return NS_OK;
}
コード例 #2
0
	/// <summary>
	/// Allows an already bound Listener to join a multicast group for receiving multicast messages.
	/// </summary>
	/// <param name="multicastAddr">The multicast IP address in dot notation.</param>
	void DgramListener::JoinMulticastGroup(const std::string& multicastAddr)
	{
		auto listener = _udpListener.lock();
		if (!listener)
		{
			throw runtime_error("Connection expired.");
		}

		auto boostIp = boost::asio::ip::address::from_string(multicastAddr);
		listener->JoinMulticastGroup(boostIp);
	}
コード例 #3
0
int main(int argc, char *argv[])
{
	filePath = argv[0];

	ReadUserDetails();
	//set handler for timer(alarm) interupt
	signal(SIGINT, InteruptHandler);

	CreateMCNetworkAddresses();

	CreateBindMCSockect();

	JoinMulticastGroup();

	RecieveMC();

	return 0;

}