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


C++ SocketServer::Open方法代码示例

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


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

示例1: main

/**
 * Entry point into kwbrouter application.
 */
int main (int argc, char* argv[])
{
    int             rc = eERR_NONE;
    bool            end_application = false;
    options_t       options;
    ioloop_t        mainloop;

    do {
        // all logs on
        log_set_mask(0xFFFFFFFF);
        log_msg(KWB_LOG_INFO, "kwbrouter...");

        // set default options for kwbrouter
        set_options(&options,
                    "",                 // no serial device
                    57600,              // baudrate, if not given
                    "/tmp/kwbr.usk",    // default address of kwbrouter socket
                    0);                 // port 0: use unix sockets

        // parse and validate commandline options
        if (parse_commandline_options(argc, argv, &options) == false ||
            validate_options(&options) == false) {
            print_usage();
            rc = eERR_BAD_PARAMETER;
            break;
        }

        ioloop_init(&mainloop);

        Router* router = new Router();

        RConnSerial* serconn = new RConnSerial(&mainloop);
        serconn->Open(options.serial_device, options.serial_baudrate);

        router->AddConnection(serconn);

        // open new server and let-every connection auto-connect to router
        create_unix_socket_file(&options);
        SocketServer* server = new SocketServer(&mainloop, router);
        server->Open(options.router_address, options.router_port);

       // RConnSocketServer server = new
 /*
        route_init(&router);

        // initialize network routing
        msg_s_init(&msg_socket);
        if ((rc = msg_s_open_server(&msg_socket, &mainloop, "/tmp/kwb.usk", 0)) != eERR_NONE) {
            break;
        }
        msg_s_set_incomming_handler(&msg_socket, handle_incomming_msg, &router);
        msg_s_set_newconnection_handler(&msg_socket, handle_new_connection, &router);
        // add route for every client of unix socket
        ep = msg_s_get_endpoint(&msg_socket, 0, eMSG_EP_COMM);

        // initialize bus routing
        msg_b_init(&msg_bus, 0);
        if (options.serial_device_set) {
            address = options.serial_device;
            port = options.serial_baudrate;
            serial = true;
        } else {
            address = options.vbusd_address;
            port = options.vbusd_port;
            serial = false;
        }
        rc = msg_b_open(&msg_bus, &mainloop, options.own_node_address, serial,
                        address, port);
        if (rc != eERR_NONE) break;
        msg_b_set_incomming_handler(&msg_bus, handle_incomming_msg, &router);
        route_add(&router, 1, 65535, address, port, eROUTE_TYPE_SERIAL, &msg_bus);
*/
        log_msg(KWB_LOG_STATUS, "entering mainloop...\n");
        while (!end_application) {
            ioloop_run_once(&mainloop);
        }

        server->Close();
        delete server;

        router->RemoveConnection(serconn);
        serconn->Close();
        delete serconn;

        delete router;
    } while (0);
    return rc;
}
开发者ID:irqmask,项目名称:koewiba-domotic,代码行数:91,代码来源:kwbrouter_main.cpp


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