Evgeniy Berezovsky
Evgeniy Berezovsky

Reputation: 19258

Share send byte[] buffer among multiple SocketAsyncEventArgs

In a scenario where I always send the same data to many clients, i.e. in a scenario where I should (and in the future will) probably switch to using (e.g. PGM) multicast, would it be thread-safe to use the the same byte[] array instance on multiple SocketAsyncEventArgs and hand them to multiple sockets via SendAsync to be sent concurrently?

After all, SendAsync should only read from the buffer, so sharing the instance shouldn't be an issue. I guess to enable reuse of that buffer afterwards, I' d have to do reference counting and there may be other issues to tackle, but my question is first and foremost about thread safety.

Upvotes: 2

Views: 85

Answers (0)

Related Questions