This article is a mirror article of machine translation, please click here to jump to the original article.

View: 930837|Reply: 381

[Source] .NET/C# Emulating WebSocket Client Connections [Source Code]

  [Copy link]
Posted on 4/20/2017 2:29:40 PM | | | |
WebSocket is a protocol that HTML5 began to provide for full-duplex communication over a single TCP connection.
In the WebSocket API, the browser and server only need to shake hands, and then a fast lane is formed between the browser and the server. Data can be transmitted directly between the two.
The browser sends a request to the server to establish a WebSocket connection through Javascrip{filter}t, and once the connection is established, the client and server can directly exchange data through the TCP connection.
When you get a Web Socket connection, you can send data to the server via the send() method and receive the data returned by the server via the onmessage event.

We know that we can use js to connect, so how to use .net/c# to simulate connecting to websockets? ?



I found a websocket online server with the address:

ws://121.40.165.18:8088

What I send him, what message he replies, so I save time to build the server.

The following is a software simulation client to connect to the websocket server, and it can be used normally.



Source code download:

Tourists, if you want to see the hidden content of this post, pleaseReply






Previous:.net/c# Speedy IP Open Port Scanner v2.0 Ultimate Version
Next:.net/c# Speedy IP Open Port Scanner v2.0 [Source]
Posted on 8/4/2021 3:24:20 PM |
void ws_OnOpen(object sender, EventArgs e)
23         {
24 SetTextBoxText(textBox1, "Connected Server" + "\r\n");
25             isConnected = true;
26
27         }
28         void ws_OnClose(object sender, CloseEventArgs e)
29         {
30 SetTextBoxText(textBox1, "Server Disconnected" + "\r\n");
31             isConnected = false;
32         }
33
34         void ws_OnMessage(object sender, MessageEventArgs e)
35         {
36             try
37             {
38                 string message = e.Data;
39
40 // Displays received server information
41                 SetTextBoxText(textBox1, message);
42
43 // Send a message to the server
44                 ws. Send("Hello World!");
45
46
47             }
48
49             catch (Exception ex)
50             {
51             }
52         }we
Posted on 1/14/2018 11:25:52 AM |
da3m0n Posted on 2018-1-14 05:03
You can also use ws://123.207.167.163:9010/ajaxchattest to find it online, and the server will automatically return what data you send.

Thanks for the addition
Posted on 4/24/2017 4:56:06 PM |
websocket address, you can also use ws://123.207.167.163:9010/ajaxchattest to find it online, what data you send, the server will automatically return to you
Posted on 4/21/2017 8:23:53 AM |
Components?
Posted on 5/4/2017 5:23:18 PM |
See what's good
Posted on 5/23/2017 9:34:26 AM |
Very good stuff
Posted on 6/1/2017 11:48:23 AM |
O great god, Mowhai
Posted on 6/2/2017 12:02:10 AM |
Take a look at learning to learn
Posted on 6/8/2017 11:11:32 AM |
Just in need, come and take a look
Posted on 6/12/2017 7:17:26 PM |
Take a look at Study
Posted on 6/13/2017 3:51:10 PM |
Learned, thank you!!!!!!!!!!!!!!!!!!
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com