© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
2 replies
Pat

❔ Reading from ClientWebSocket with BinaryReader

I am building an app to work as a gateway between a consumer connecting to a .NET websocket server and then proxying that to a TCP backend server. This code currently works quite well for TCP clients and makes use of the BinaryReader / BinaryWriter to proxy between the WebSocket and the TCPClient classes.

I'm trying to replicate the same behavior between a ClientWebSocket and a Websocket but can't seem to find a solution to reading each "packet" the binary ClientWebSocket receives. Wireshark shows the data I would expect but calling ClientWebSocket.ReceiveAsync results in odd counts that do not match the packets.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅BinaryReader reads garbage when reading from compressed stream
C#CC# / help
6mo ago
BinaryReader Question
C#CC# / help
4y ago
✅ ClientWebSocket concurrency question
C#CC# / help
4y ago
❔ Confusing ClientWebSocket.ReceiveAsync() behavior
C#CC# / help
3y ago