//// server.cpp// ~~~~~~~~~~//// Copyright (c) 2003-2016 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<ctime>#include<iostream>#include<string>#include<boost/asio.hpp>usingboost::asio::ip::tcp;std::stringmake_daytime_string(){usingnamespacestd;// For time_t, time and ctime;time_tnow=time(0);returnctime(&now);}intmain(){try{boost::asio::io_serviceio_service;tcp::acceptoracceptor(io_service,tcp::endpoint(tcp::v4(),13));for(;;){tcp::socketsocket(io_service);acceptor.accept(socket);std::stringmessage=make_daytime_string();boost::system::error_codeignored_error;boost::asio::write(socket,boost::asio::buffer(message),ignored_error);}}catch(std::exception&e){std::cerr<<e.what()<<std::endl;}return0;}
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.