![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Classic ASP) Asynchronous SSL Client (Deprecated) ExampleNotice: The functionality described here is deprecated and replaced by a newer model for asynchronous method calls. The newer model was introduced in Chilkat v9.5.0.52, and is identified by methods having names ending in “Async” which return a task object. Demonstrates how to connect to an SSL server, send a simple message, receive a simple response, and disconnect. This example uses the asynchronous methods to connect, send, and receive.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% ' Notice: The functionality described here is deprecated and replaced ' by a newer model for asynchronous method calls. The newer model was ' introduced in Chilkat v9.5.0.52, and is identified by methods ' having names ending in “Async” which return a task object. ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Socket") set socket = Server.CreateObject("Chilkat.Socket") ssl = 1 maxWaitMillisec = 20000 ' The SSL server hostname may be an IP address, a domain name, ' or "localhost". You'll need to change this: sslServerHost = "123.123.88.88" sslServerPort = 8123 ' Connect to the SSL server asynchronously in a background thread. success = socket.AsyncConnectStart(sslServerHost,sslServerPort,ssl,maxWaitMillisec) If (success <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( socket.LastErrorText) & "</pre>" Response.End End If ' Wait for the socket to become connected... Do While (socket.AsyncConnectFinished <> 1) ' Sleep 1 second. socket.SleepMs 1000 Loop ' Did the connect fail? If (socket.AsyncConnectSuccess <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( socket.AsyncConnectLog) & "</pre>" Response.End End If ' Set maximum timeouts for reading an writing (in millisec) socket.MaxReadIdleMs = 20000 socket.MaxSendIdleMs = 20000 ' Send a "Hello Server! -EOM-" message: success = socket.AsyncSendString("Hello Server! -EOM-") If (success <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( socket.LastErrorText) & "</pre>" Response.End End If ' Wait for the send to finish Do While (socket.AsyncSendFinished <> 1) ' Sleep 1 second. socket.SleepMs 1000 Loop ' Did the send fail? If (socket.AsyncSendSuccess <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( socket.AsyncSendLog) & "</pre>" Response.End End If ' The server (in this example) is going to send a "Hello Client! -EOM-" ' message. Begin reading asynchronously in a background thread: success = socket.AsyncReceiveUntilMatch("-EOM-") If (success <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( socket.LastErrorText) & "</pre>" Response.End End If ' Wait for the background read to finish Do While (socket.AsyncReceiveFinished <> 1) ' Sleep 1 second. socket.SleepMs 1000 Loop ' Did the receive fail? If (socket.AsyncReceiveSuccess <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( socket.AsyncReceiveLog) & "</pre>" Response.End End If ' Display the received message: Response.Write "<pre>" & Server.HTMLEncode( socket.AsyncReceivedString) & "</pre>" ' Close the connection with the server ' Wait a max of 20 seconds (20000 millsec) success = socket.Close(20000) %> </body> </html> |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.