Is the effect of .Net.Sockets the same as that of Websocket?

there is an existing project that needs to transfer .net to JS, and is stuck in a place where Socket communications are available.

use socket to communicate in C-sharp.Net, just use the Socket class

int socket( int url, int type, int protocol);
//url:
//type:socket
//protocol:

now I"m going to use JS"s websocket instead of .net. Sockets, but I made an error after rewriting it. I don"t know if it"s the following reason.
ws"s API goes like this:

ws = new WebSocket(url);
//socket

1) WS is based on TCP and lacks two parameters. Is the effect the same? Can WS replace .NetSocket?
2) if it can not be replaced, what should be used to solve it?


should not be the same thing, or not exactly. The websocket in js is that websocket, is used for real-time notification, and the connection is the address of websocket, so you need to create a backend websocket address first, and then use js to connect.


the difference is that socket uses the communication of TCP, while websocket is the HTTP protocol during the connection phase, and the TCP protocol is only after the connection, so you can't do this. Net is made up of dedicated websocket components.

Please refer to https://www.cnblogs.com/pengz.

Menu