Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 1774

Create a websocket connection

by Anoraku - 26 December, 2019 - 07:44 PM
This post is by a banned member (Anoraku) - Unhide
Anoraku  
Supreme
10
Posts
2
Threads
4 Years of service
#1
I've been struggling with this for the last week. Anyone has some advices on how to do it?
Basically I have a website that connects with the browser using a websocket connection and start exchanging data. I want to reproduce that in my vb.net program.

How can I do that? From my research I know I need to initiate a GET request at first and upgrade it to websocket.

Should I use the Chilkat library? (thats what I've found on google, but I was not able to use it)
Or maybe I should use the System.net.websocket namespace? (again I tried and I cant understand how to use it)

I appreciate any help. Thanks! [Image: blackhat.gif]
This post is by a banned member (RoDaBaFilms) - Unhide
8
Posts
0
Threads
4 Years of service
#2
A quick google search gives me a library called websocket-sharp.
I personally have not used this library (yet), but nonetheless it looks really good and it seems the code somewhat resembles the JS counterpart.
It's documentated really good as well, but the examples are written in C# however (so I hope you can read and convert C# to VB.net), but it should work in VB.net too.

I have translated the first example (not tested, just translated) so you can try and create your application from there (using Quote instead of Code block because Code block broken :/ )
Quote:Public Shared Sub Main(args As String())
    Using ws As New WebSocket("ws://dragonsnest.far/Laputa")
        AddHandler ws.OnMessage, Sub(sender, e)
            Console.WriteLine("Laputa says: " + e.Data)
        End Sub
        
        ws.Connect()
        ws.Send("BALUS")
        Console.ReadKey(True)
    End Using
End Sub

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)