Visual FoxPro
Visual FoxPro
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 FoxPro Downloads
LOCAL lnSuccess
LOCAL loSocket
LOCAL lnBSsl
LOCAL loRest
LOCAL lnBAutoReconnect
LOCAL lcResponseText
lnSuccess = 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.
loSocket = CreateObject('Chilkat.Socket')
lnBSsl = 1
lnSuccess = loSocket.Connect("example.com",443,lnBSsl,5000)
IF (lnSuccess <> 1) THEN
? loSocket.LastErrorText
RELEASE loSocket
CANCEL
ENDIF
loRest = CreateObject('Chilkat.Rest')
* Use the connected socket as the transport. The 2nd argument enables automatic reconnection.
lnBAutoReconnect = 1
lnSuccess = loRest.UseConnection(loSocket,lnBAutoReconnect)
IF (lnSuccess = 0) THEN
? loRest.LastErrorText
RELEASE loSocket
RELEASE loRest
CANCEL
ENDIF
lcResponseText = loRest.FullRequestNoBody("GET","/api/status")
IF (loRest.LastMethodSuccess = 0) THEN
? loRest.LastErrorText
RELEASE loSocket
RELEASE loRest
CANCEL
ENDIF
? lcResponseText
RELEASE loSocket
RELEASE loRest