ソケットの周りに C++ イテレータ ファサードの適切な実装 (ライブラリ) があるかどうか疑問に思っていました。Boost Iterator ライブラリと ASIO を調べましたが、何も見つかりません。オープンソースのソリューションは素晴らしいでしょう!
次のユースケースの解決策を探しています。
int socket_handler = 0;
socket_iterator it(socket_handler);
socket_iterator end;
//read mode 1:
while (it != end)
{
char c = *it;
.
.
++it;
}
//read mode 2:
while (it != end)
{
std::string s = *it;
.
.
++it;
}
//write mode 1:
unsigned char c = 0;
while (c < 100)
{
*it = c++;
.
.
++it;
}
//write mode 2:
std::sttring s = "abc";
for (unsigned int i = 0; i < 10; ++i)
{
*it = s;
.
.
++it;
}
注: 接続が切断されると == 終了します。