lundi 4 juillet 2016

boost asio cloase bind socket

On the first run - bind successful, when i restart program - error 10048( address already use) without calling close and shutdown - restart everything is fine boost::asio::io_service _ioService; boost::asio::ip::tcp::socket _socket(_ioService); boost::system::error_code err; _socket.open(boost::asio::ip::tcp::v4(), err); if (err.value()) { cout<<err.value()<<endl; cout << err.message() << endl; } _socket.bind(boost::asio::ip::tcp::endpoint(boost::asio::ip::address_v4::from_string("127.0.0.1"), 1276), err); cout << err.value() << endl; if (err.value()) { cout << err.value() << endl; cout << err.message() << endl; } _socket.connect(boost::asio::ip::tcp::endpoint(boost::asio::ip::address_v4::from_string("127.0.0.1"), 1500), err); if (err.value()) { cout << err.value() << endl; cout << err.message() << endl; } _socket.shutdown(_socket.shutdown_both); _socket.close(err); if (err.value()) { cout << err.value() << endl; cout << err.message() << endl; }

Aucun commentaire:

Enregistrer un commentaire