0
Maybe the title is a bit silly, but I’ll explain, I have a Server Socket that I did in VB and I also have a Client Socket made in Javascript for web, only problem is that for Client(Web) understand that the connection established is necessary that the server return 101, otherwise:
it stays in "Pending" until we disconnect, still do not know how to make the server return this, Someone could explain how to do?
It was already a bit boring to develop the server in Visual Basic because the examples I found on the internet were very simple, my code also rsrs
Imports System.Net.Sockets
Imports System.IO
Imports System.Threading
Imports System.Net
Module Principal
Dim ServerIP As IPAddress = IPAddress.Parse("192.168.0.3")
Dim Server As New TcpListener(ServerIP, 80)
Dim Client As New TcpClient
Dim Reader As StreamReader
Dim Writer As StreamWriter
Sub Main()
Server.Start()
Client = Server.AcceptTcpClient
Dim Thread As New Thread(AddressOf Receive)
Thread.Start()
While Client.Connected
Dim m = Console.ReadLine
If Len(m) Then
Writer = New StreamWriter(Client.GetStream)
Writer.WriteLine(m)
Writer.Flush()
End If
End While
End Sub
Sub Receive()
While Client.Connected
Reader = New StreamReader(Client.GetStream)
Dim Received = Reader.ReadLine
If Len(Received) Then
Console.WriteLine(Received)
End If
End While
Main()
End Sub
End Module
Well, if anyone can help I’d really appreciate it.
You are aware that there is a whole protocol you need to write to make the VB serve Websockets, right? More details here: What are Network Sockets and Websockets?
– Bacco
from what I’ve seen has the "101 Switching Protocols", I’m still struggling to implement but thanks man, thanks.
– Paulo Abreu
This is just the beginning. You have to do the whole Handshake, provide the headers, and when you exchange data, it has a standardized format. Websockets have a very poorly chosen name (almost always web patterns are poorly made), it has nothing to do with normal sockets.
– Bacco