SteamRE / SteamKit

SteamKit2 is a .NET library designed to interoperate with Valve's Steam network. It aims to provide a simple, yet extensible, interface to perform various actions on the network.
GNU Lesser General Public License v2.1
2.5k stars 478 forks source link

Async/await network methods #325

Open jacobs100500 opened 7 years ago

jacobs100500 commented 7 years ago

Do you plan to add an async/await methods to work with the Steam network? When multiple accounts work is not very good to use synchronous methods. And the use of one thread (NetThread in the TcpConnection class) per account, consumes more resources than using async/await.

voided commented 7 years ago

We have some async/await support in the form of job messages, but this is mostly a developer nicety rather than any form of IO optimization.

Under the hood, we still use a distinct networking thread per client instance.

Is there a specific use case you have where thread-per-client is not scaling very well? I'm not entirely sure if we have any plans to support scaling up the number of clients SteamKit is capable of supporting at once, but it might be something we can investigate in the future.

jacobs100500 commented 7 years ago

I run a lot of bots (>100), then created at least 100 threads. All operations of read/write are blocking all this threads. Heartbeat function are blocks the thread every 5 seconds, without regard to other IO operations. Also, the callback manager when wait callback are blocking the main(!!!) thread. Because of this, my program is freezing or crashed on no respond. I rewrote the problem areas using async/await and the problem was solved. I can send the rewrited code.

mika76 commented 7 years ago

I'd be interested in this - please 😊