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