当前位置: 首页>>代码示例>>C++>>正文


C++ Message::AddProgram方法代码示例

本文整理汇总了C++中Message::AddProgram方法的典型用法代码示例。如果您正苦于以下问题:C++ Message::AddProgram方法的具体用法?C++ Message::AddProgram怎么用?C++ Message::AddProgram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Message的用法示例。


在下文中一共展示了Message::AddProgram方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
        puts ("+ Nothing to do. Exiting.");
        return 0;
    }

    if(config.GetType() == TYPE_SAP)
    {
        printf("+ Packet TTL set to %u\n",config.GetTTL());
        printf("+ Running as %s.\n",
               config.GetDaemonMode() ? "daemon" : "program");

        /* Create the broadcast object */
        Broadcast broadcast (config.GetTTL (), config.GetInterface ());

        vector<Announce *> announces;

        for (unsigned int i = 0; i < config.Programs.size(); i++)
        {
            Program *program = config.Programs[i];

            Announce *announce = new Announce;
            if (broadcast.GuessDestination (program->GetAddress ().c_str (),
                                            &announce->addr,
                                            &announce->addrlen))
            {
                fputs("- Network initialization failed. Aborting\n", stderr);
                delete announce;
                /* FIXME memory leak in announces */
                return 1;
            }

            /* Create a new message */
            Message *message = new Message(0x4212+i, "1.2.3.4");
            /* Add the program */
            message->AddProgram(config.Programs[i]);

            announce->message = message;
            announces.push_back( announce );
        }

        /* Forking if necessary */
        if(config.GetDaemonMode())
        {
            puts("+ Forking ... \n");
            daemon(0,0);
        }

        unsigned n = config.Programs.size();
        lldiv_t d = lldiv (1000000000LL * config.GetDelay() / n, 1000000000);
        struct timespec delay;
        delay.tv_sec = d.quot;
        delay.tv_nsec = d.rem;

        signal (SIGINT, exit_handler);
        signal (SIGTERM, exit_handler);
        signal (SIGHUP, exit_handler);
        signal (SIGQUIT, exit_handler);
        setvbuf (stdout, NULL, _IONBF, 0);

        while(!should_exit)
        {
            for( unsigned int i = 0; i< announces.size() ; i ++ )
            {
                Announce *announce = announces[i];
                /* Send the message */
                if (broadcast.Send (announce->message ,
                                    (struct sockaddr *)&announce->addr,
开发者ID:bobek,项目名称:minisapserver-debian,代码行数:67,代码来源:sapserver.cpp


注:本文中的Message::AddProgram方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。