Daytime.4 - 동기식 UDP daytime 클라이언트 (A synchronous UDP daytime client) 이 튜토리얼 프로그램은 asio를 사용하여 UDP용 클라이언트 응용프로그램을 구현하는 방법을 보여준다. #include #include #include using boost::asio::ip::udp; 응용프로그램의 시작은 TCP daytime 클라이언트와 기본적으로 동일하다. int main(int argc, char* argv[]) { try { if (argc != 2) { std::cerr
Daytime.3 소스 (Source listing for Daytime.3) // // 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.3 - 비동기식 TCP daytime 서버 (An asynchronous TCP daytime server) main() 함수 int main() { try { 들어오는 클라이언트 연결을 승인하려면 서버 개체를 생성해야 한다. io_context 개체는 서버 개체가 사용할 소켓과 같은 I/O 서비스를 제공한다. boost::asio::io_context io_context; tcp_server server(io_context); io_context 개체를 실행하여 사용자를 대신하여 비동기 작업을 수행한다. io_context.run(); } catch (std::exception& e) { std::cerr start(); } start_accept(); } tcp_connection 클래..
Daytime.2 소스 (Source listing for Daytime.2) // // 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 using boost::asio::ip::tcp; std::string make_d..
Daytime.2 - 동기식 TCP daytime 서버 (A synchronous TCP daytime server) 이 튜토리얼 프로그램은 asio를 사용하여 TCP용 서버 응용프로그램을 구현하는 방법을 보여준다. #include #include #include #include using boost::asio::ip::tcp; 클라이언트로 다시 보낼 문자열을 생성하는 make_daytime_string() 함수를 정의한다. 이 함수는 모든 daytime 서버 응용프로그램에서 재사용될 것이다. std::string make_daytime_string() { using namespace std; // For time_t, time and ctime; time_t now = time(0); return ct..