Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Main.bas
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Dim sizeStatusCode As Long ' for HTTP result request
sizeStatusCode = 4 ' four bytes for long ' for HTTP result request
dwError = ERROR_SUCCESS
fStatus = False
Dim hSessionHandle As Long
Dim hConnectionHandle As Long
Dim hRequestHandle As Long
Dim hWebSocketHandle As Long
Dim hSessionHandle As LongPtr
Dim hConnectionHandle As LongPtr
Dim hRequestHandle As LongPtr
Dim hWebSocketHandle As LongPtr
hSessionHandle = 0
hConnectionHandle = 0
hRequestHandle = 0
Expand All @@ -31,16 +31,15 @@ Dim AgentHeader As String
AgentHeader = "Websocket Sample"

' Create session handle
hSessionHandle = WinHttpOpen(StrPtr(AgentHeader), _
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, 0, 0, 0)
hSessionHandle = WinHttpOpen(StrPtr(AgentHeader), WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, 0, 0, 0)
If hSessionHandle = 0 Then
dwError = GetLastError
GoTo quit
End If

' Server Name
Dim ServerName As String
ServerName = "echo.websocket.org"
ServerName = "ws.vi-server.org"

' Server Port
Dim Port As Long
Expand All @@ -56,7 +55,7 @@ End If
' Request Method & Path
Dim method As String, Path As String
method = "GET" ' always
Path = "/" ' echo.websocket.org
Path = "/mirror" ' echo.websocket.org

' Create request handle - use 0 for null pointer to empty strings: Version, Referrer, AcceptTypes
hRequestHandle = WinHttpOpenRequest(hConnectionHandle, StrPtr(method), StrPtr(Path), 0, 0, 0, 0)
Expand Down Expand Up @@ -160,7 +159,7 @@ Dim dwBufferLength As Long
' get correct value in case of change to buffer size
dwBufferLength = (UBound(rgbBuffer) - LBound(rgbBuffer) + 1)

Dim pbCurrentBufferPointer As Long
Dim pbCurrentBufferPointer As LongPtr
pbCurrentBufferPointer = VarPtr(rgbBuffer(0))
Dim dwBytesTransferred As Long
dwBytesTransferred = 0
Expand Down Expand Up @@ -283,4 +282,3 @@ End Sub




6 changes: 3 additions & 3 deletions WinHttpCommon.bas
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ Public Declare PtrSafe Function WinHttpWebSocketReceive Lib "winhttp" ( _
ByVal hWebSocket As LongPtr, _
ByRef pvBuffer As Any, _
ByVal dwBufferLength As Long, _
ByRef pdwBytesRead As LongPtr, _
ByRef peBufferType As LongPtr _
ByRef pdwBytesRead As Long, _
ByRef peBufferType As Long _
) As Long

Public Declare PtrSafe Function WinHttpWebSocketClose Lib "winhttp" ( _
Expand All @@ -154,7 +154,7 @@ Public Declare PtrSafe Function WinHttpWebSocketQueryCloseStatus Lib "winhttp" (
ByRef usStatus As Integer, _
ByRef pvReason As Any, _
ByVal dwReasonLength As Long, _
ByRef pdwReasonLengthConsumed As LongPtr _
ByRef pdwReasonLengthConsumed As Long _
) As Long

Public Declare PtrSafe Function WinHttpQueryHeaders Lib "winhttp" ( _
Expand Down