開いている TcpClient オブジェクトがたくさん (約 1000 としましょう) ある C# プログラムを持っています。それらの接続のいずれかで何かが起こるのを待つ状態に入りたいです。
接続ごとにスレッドを起動したくありません。
何かのようなもの...
while (keepRunning)
{
// Wait for any one connection to receive something.
TcpClient active = WaitAnyTcpClient(collectionOfOpenTcpClients);
// One selected connection has incomming traffic. Deal with it.
// (If other connections have traffic during this function, the OS
// will have to buffer the data until the loop goes round again.)
DealWithConnection(active);
}
追加情報:
TcpClient オブジェクトは TcpListener から取得されます。
ターゲット環境は、MS .NET または Mono-on-Linux になります。
プロトコルは、接続が開いている間、長時間のアイドル状態を要求します。