rest - C++ boost bad file descriptor -
above code im using calling browser , other client. doesnt seem work. there wrong? want know on ip im running server , how can used create restful webservice.
#include <ctime> #include <iostream> #include <string> #include <boost/asio.hpp> using boost::asio::ip::tcp; using namespace std; std::string make_daytime_string() { using namespace std; // time_t, time , ctime; time_t = time(0); return ctime(&now); } int main() { try { boost::asio::io_service io_service; tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 13)); (;;) { cout << "listening socket" << endl; tcp::socket socket(io_service); acceptor.accept(socket); cout << "listening socket" << endl; std::string message = make_daytime_string(); boost::system::error_code ignored_error; boost::asio::write(socket, boost::asio::buffer(message), ignored_error); } } catch (std::exception &e) { std::cerr << e.what() << std::endl; } }
i'd guess not running program sufficient permission open privileged (<1024) port 13.
trying 1313 works me (without administrative privileges)