Visual Basic 6.0
Visual Basic 6.0
Use an Existing Socket Connection for REST
See more REST Examples
Demonstrates Rest.UseConnection, which supplies an already-connected Socket as the transport for REST requests instead of calling Connect. This is useful when the connection must be established with specific socket options or shared across objects.
Background. Rest can operate over any connected socket. The second argument enables automatic reconnection so a dropped connection is transparently re-established between requests.
Chilkat Visual Basic 6.0 Downloads
Dim success As Long
success = 0
' Demonstrates supplying an already-connected socket for the REST transport. This is useful when
' the connection must be established with specific socket options, or reused across objects.
Dim socket As New ChilkatSocket
Dim bSsl As Long
bSsl = 1
success = socket.Connect("example.com",443,bSsl,5000)
If (success <> 1) Then
Debug.Print socket.LastErrorText
Exit Sub
End If
Dim rest As New ChilkatRest
' Use the connected socket as the transport. The 2nd argument enables automatic reconnection.
Dim bAutoReconnect As Long
bAutoReconnect = 1
success = rest.UseConnection(socket,bAutoReconnect)
If (success = 0) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
Dim responseText As String
responseText = rest.FullRequestNoBody("GET","/api/status")
If (rest.LastMethodSuccess = 0) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
Debug.Print responseText