'WebSocket with json in c#

I have this python code

  try:
               ws = websocket.create_connection(f"{ws_server}",origin=f"url")
               ws.send(js2.dumps(JSON DATA)).encode("UTF-8"))
               ws.send(js2.dumps(JSON DATA)).encode("UTF-8"))
               ws.send(js2.dumps(JSON DATA)).encode("UTF-8"))
              
               ws.close()
           except Exception as e:
               print(e)
               pass

How can I make that code in c# , and send that json data too



Solution 1:[1]

Try using https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.tcplistener?view=net-6.0 It's the C# TCP library

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dutch