voidrun(void){ constchar* addr = "127.0.0.1:8088"; acl::server_socket server; if (!server.open(addr)) { // Bind and listen the local address. return; }
while (true) { acl::socket_stream* conn = server.accept(); // Wait for connection. if (conn == NULL) { break; } std::thread thread([=] { // Start one thread to handle the connection. char buf[256]; int ret = conn->read(buf, sizeof(buf), false); // Read data. if (ret > 0) { conn->write(buf, ret); // Write the received data. } delete conn; }); thread.detach(); } }
target_link_libraries(test PUBLIC acl_all) target_link_directories(test PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib> $<INSTALL_INTERFACE:lib> )
target_include_directories(test PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/acl-lib> $<INSTALL_INTERFACE:include/acl-lib> PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src )