Sample code for 30+ languages & platforms
Visual FoxPro

Disconnect from a REST Server

See more REST Examples

Demonstrates Rest.Disconnect, which closes the current HTTP connection. The argument is the maximum number of milliseconds to wait for the close to complete.

Background. Connections are normally kept alive for reuse. Disconnect is used when an application wants to explicitly release the connection rather than relying on keep-alive or object destruction.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loRest
LOCAL lnBTls
LOCAL lnBAutoReconnect
LOCAL lcResponseText
LOCAL lnBDisconnected

lnSuccess = 0

loRest = CreateObject('Chilkat.Rest')

*  Connect to the REST server.  The 3rd argument enables TLS (use 1 for HTTPS on port 443),
*  and the 4th enables automatic reconnection if the connection is dropped between requests.
lnBTls = 1
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("example.com",443,lnBTls,lnBAutoReconnect)
IF (lnSuccess = 0) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

lcResponseText = loRest.FullRequestNoBody("GET","/api/status")
IF (loRest.LastMethodSuccess = 0) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

? lcResponseText

*  Close the connection.  The argument is the maximum number of milliseconds to wait for the
*  close to complete.
lnBDisconnected = loRest.Disconnect(200)
IF (lnBDisconnected <> 1) THEN
    ? "The disconnect did not complete within the wait time."
ENDIF

? "Done."

RELEASE loRest