简体   繁体   中英

Web socket client JavaScript?

i created TCP Client Using Web Socket 'JavaScript' and it can connect to C# TCP Server but i can't replay in C# to handshaking sent by JavaScript TCP Client Please Help !

thanks.

There's no way we can help you here in any specific way without seeing your code on both client and server. webSocket is a protocol, not just a plain TCP connection. For your C# server to successfully accept a webSocket connection from any client, it must follow the entire webSocket protocol.

This reference Writing WebSocket Servers provides a pretty good summary of what a server has to do in order to successfully "speak" webSocket. Unless this is merely a learning exercise for you, you will probably want to get a library/class for C# that already implements a webSocket server as I'm sure there are many.

To give you a general idea, all webSocket connections start with an HTTP request that includes an "upgrade" header, a security key and a version. If the server agrees to the upgrade, then it responds with a security key. At that point, the two sides switch from HTTP to the webSocket protocol on that same socket and from then on, all data is then sent using the webSocket Frame format. This information is all outlined in the earlier MDN reference about creating webSocket servers.

Here is an article about writing webSockets servers in C#:

MDN: Writing a WebSocket server in C#

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM