0

I was using older version of handshake(with two keys) and everything was fine. Now I'm creating Sec-WebSocket-Accept key, and manage to connect to the server. But as soon as I send message to connected client, it get disconnected. I guess those lines of code are wrong, but I can not find working example of sending data(examples are mainly for older WS version)

ConnectionSocket.Send(New Byte() {CByte(WrapperBytes.Start)}, 1, 0)
ConnectionSocket.Send(Encoding.UTF8.GetBytes(str))
ConnectionSocket.Send(New Byte() {CByte(WrapperBytes.[End])}, 1, 0)
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
zmrcic
  • 5
  • 3

1 Answers1

1

See the latest draft of the spec for how to send/receive data now.

It'd also be worth checking which version of web sockets is supported by your browser.

In case it helps, I've written a C++ example. The WsProtocol80 class shows how to read/write data.

Community
  • 1
  • 1
simonc
  • 41,632
  • 12
  • 85
  • 103
  • Thanks,can not read c++...vb or c# will be great. I have read many articles and specification but can not manage code to work. Simple "Hello world" will do the magic. – zmrcic Nov 15 '11 at 10:12
  • Which version of web sockets are you trying to implement now? (Or, alternatively, which browser/version are you testing with?) Assuming v8 or later for web sockets, [a previous question](http://stackoverflow.com/questions/8125507/how-can-i-send-and-receive-websocket-messages) was answered with pseudocode showing how to send & receive messages. – simonc Nov 15 '11 at 12:06
  • draft-ietf-hybi-thewebsocketprotocol-15 and chrome v15 – zmrcic Nov 15 '11 at 12:35
  • Thanks. The [previous question](http://stackoverflow.com/questions/8125507/how-can-i-send-and-receive-websocket-messages) should cover things for you then. – simonc Nov 15 '11 at 13:04