Sample code for 30+ languages & platforms
Visual Basic 6.0

Revert a TLS Connection to Plain TCP

See more Socket/SSL/TLS Examples

Demonstrates Socket.ConvertFromSsl, which ends the TLS layer while leaving the underlying TCP connection open for subsequent unencrypted communication.

Background. This is the reverse of a STARTTLS-style upgrade and is valid only while TLS is currently active on the connection.

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

Dim socket As New ChilkatSocket

'  Connect to the server using TLS.
Dim bTls As Long
bTls = 1
Dim maxWaitMs As Long
maxWaitMs = 5000
success = socket.Connect("example.com",5000,bTls,maxWaitMs)
If (success = 0) Then
    Debug.Print socket.LastErrorText
    Exit Sub
End If

'  End the TLS layer while keeping the underlying TCP connection open for subsequent unencrypted
'  communication.  This is the reverse of a STARTTLS-style upgrade and is valid only while TLS is
'  active.
success = socket.ConvertFromSsl()
If (success = 0) Then
    Debug.Print socket.LastErrorText
    Exit Sub
End If

Debug.Print "Reverted to a plain TCP connection."