Reputation: 671
This is my first time to write socket programs and I don't how to implement websocket ping/pong and close control frames in RFC 6455 in C# ( without any third party libraries, I want to implement manually ). Is there someone who has implemented already these control frames in C# or any other programing languages? Please give any sample solutions or correct direction. Thanks a lot!
Upvotes: 3
Views: 4097
Reputation: 19221
Close frames have an op code of 8. You can answer it with a close frame (it will be ignored), but then disconnect.
Pings have an op code of 9. You need to answer any ping with a pong.
Pongs have an op code of 10. Pongs don't need to be answered.
To answer a Ping, the Pong should contain the body of the message sent with the Ping.
Remember a Ping and a Pong can be sent in the middle of a multi-framed message!
You can find a Ruby implementation within The Plezi Framework's Websocket Protocol source code.
I'm sure there are C# implementations as well. @ThomasLevesque suggested WebSocket4Net... maybe that would fit what you're searching for a bit better.
Good Luck!
Upvotes: 1