Using HTTPSecureSocket

Hello everyone.

I need your help, because this is a topic I know very little about.

A program written with Xojo 2019r1.1 needs to access a web space on a Windows Server and read the content of a text file.

Until a few days ago, everything worked perfectly using HTTPSocket; the provider changed the space from http to https. So I am trying to use HTTPSecureSocket, but after connecting to the web folder, when I try to read the text file with Get, it gives me error 102 (Lost Connection).

This is the code I am using:

Dim HS As New HTTPSecureSocket
HS.Address = updURL
HS.Port = 443
HS.Connect

While Not HS.IsConnected
  If HS.LastErrorCode <> 0 Then
    lblMsg.Text = "Socket Error: " + Str(HS.LastErrorCode)
    lblMsg.Refresh
    Return
  End If
  // Poll the socket to let it do its thing
  HS.Poll
Wend

// Lettura file NumSerie.txt
If HS.IsConnected Then
  lblMsg.Text = "Connesso al sito: verifico presenza aggiornamenti."
  lblMsg.Refresh
  // Lettura sincrona del file 
  st = HS.Get(updURL + "/" + updFolder + "/NumSerie.txt", 0)  // error 102
  If HS.LastErrorCode <> 0 Then
    lblMsg.Text = "ERRORE: " + Str(HS.ErrorCode)
  End If            
  
  HS.Close
  HS = Nil
Else
  // The socket broke out of the loop due to an error
  lblMsg.Text = "Connessione al sito degli aggiornamenti non riuscita."
  lblMsg.Refresh
  Exit Sub
End If

I hope there is somebody who can help me!

Thank you all.

Nedi

I could be wrong but I think HTTPSecureSocket only supports older SSL / TLS protocols so you might need to switch to URLConnection.

2 Likes

Thank you, Kevin: it works! And it’s simpler than using HTTPSecureSocket.

1 Like