掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
boost::asioでTCPクライアントサーバーの構築をしたいのですが…… (ID:70024)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
修正してみました クライアント側 std::string line; ip::address addr=ip::address::from_string("192.168.1.12"); tcp::iostream s(tcp::endpoint(addr, 10800)); s << "allow\n"; s << flush; while(getline(s, line)) { cout << line << endl; } サーバ側 io_service io; std::string line; ip::tcp::acceptor acc(io, ip::tcp::endpoint(ip::tcp::v4(), 10800)); for (;;) { // 接続待ち ip::tcp::iostream s; acc.accept(*s.rdbuf()); getline(s, line); cout << line << endl; s << "123\n"; s << flush; } // ここでサーバ側のsはcloseされるのでクラインとの通信が切れる。 VC9で動作確認済みです。
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.