Daytime.7 - 결합된 TCP/UDP 비동기식 서버 (A combined TCP/UDP asynchronous server) 이 튜토리얼 프로그램은 이전 튜토리얼에서 작성한 두 개의 비동기 서버를 단일 서버 응용프로그램으로 결합하는 방법을 보여준다. main() 함수 int main() { try { boost::asio::io_context io_context; TCP 클라이언트 연결을 승인하는 서버 개체를 만드는 것으로 시작을 한다. tcp_server server1(io_context); 또한, UDP 클라이언트 요청을 승인하는 서버 개체도 필요하다. udp_server server2(io_context); io_context 개체가 수행할 두 가지 그룹으로 작업을 생성했다. io_contex..
Daytime.6 소스 (Source listing for Daytime.6) // // server.cpp // ~~~~~~~~~~ // // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include #include #include #include #include #include #include using boost::asio::..
Daytime.5 소스 (Source listing for Daytime.5) // // server.cpp // ~~~~~~~~~~ // // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include #include #include #include #include using boost::asio::ip::udp; std::stri..
Daytime.5 - 동기식 UDP daytime 서버 (A synchronous UDP daytime server) 이 튜토리얼 프로그램은 asio를 사용하여 UDP용 서버 응용프로그램을 구현하는 방법을 보여준다. int main() { try { boost::asio::io_context io_context; UDP 포트 13번에서 요청을 수신 할 ip::udp::socket 개체를 생성한다. udp::socket socket(io_context, udp::endpoint(udp::v4(), 13)); 클라이언트에서 요청을 시작할 때까지 기다린다. remote_endpoint 개체는 ip::udp::socket::receive_from()에 파라미터로 주어지게 된다. for (;;) { boost::..