Properties and methods in the SSLSocket class.
The INET::SSLSocket object is a version of INET::Socket that supports reading and writing data between client and server computers. The following code provides an overview of how socket communications are designed.
dim ServerSocket as INET::Socket dim ClientSocket as INET::Socket dim CTX as INET::SSLContext Define CTX properties ServerSocket.Listen() ServerSocket.Accept(ClientSocket)
- dim LocalSocket as INET::Socket LocalSocket.Connect() LocalSocket.Write()
- There may be more exchanges of data.
- More sessions with other client computers.
This example code shows how to use the methods of the INET::SSLSocket object.
dim ssl as inet::sslsocket dim Result as C dim Temp as C ssl.context.requirevalidcertificate = .f. if ssl.connect("toshiba1000", 443, 2000) then if ssl.write("GET / HTTP/1.0" + crlf() + crlf()) then FoundData = ssl.read(temp, 10000, -1) while FoundData on error resume next Result = Result + Temp FoundData = .f. if ssl.isopen then FoundData = ssl.read(temp, 10000, -1) end if end while a5_show_variable(Result, "Test OpenSSL HTTP Client - Response") else ui_msg_box("Request Error", ssl.callresult.text) end if ssl.close() else ui_msg_box("Connect Error", ssl.callresult.text) end if
This code illustrates a simple SSL HTTP Server.
dim ResponseHeader as C dim ResponseFooter as C dim ctx as INET::SSLContext dim ssl as inet::sslsocket dim doc as inet::httpdocument dim Request as C dim Temp as C ResponseHeader = <<%str% HTTP/1.1 200 OK Server: SampleAlphaFiveSSL Content-Type: text/html Request %str% ResponseFooter = <<%str%
Logical IsBusy property
Logical IsOpen property
Logical IsReadable property
Logical IsWriteable property
String RemoteAddress property
String LocalAddress property
Numeric RemotePort property
Numeric LocalPort property
Numeric Handle property
Logical Blocking property
Logical Broadcast property
Logical Debug property
Logical Delay property
Logical KeepAlive property
Logical Linger property
Logical OutOfBandInLine property
Logical Route property
Numeric ReceiveBufferSize property
Numeric ReceiveTimeout property
Logical ReuseAddress property
Numeric SendBufferSize property
Numeric SendTimeout property
Numeric BytesAvailable property
Logical IsListening property
- Accept Method
The INET::SSLSocket::Accept() method accepts a new connection (the socket must already be listening). The method returns a status object with information about the success of the call. If the call is successful, AcceptedSocket contains the new instance of INET::Socket. HandshakeReadTimeout is appropriate for SSL sockets only.
- Close Method
The INET::SSLSocket::Close() method closes an open connection.
- Connect Method
The INET::SSLSocket::Connect() method opens a connection to the requested host and port. Note: ConnectTimeout is in milliseconds.
- CreateCertificateRequest Method
The INET::SSLSocket::CreateCertificateRequest() method creates a request for a certificate.
- GetOptions Method
The INET::SSLSocket::GetOptions() method reads the status of one or more option values.
- Listen Method
The INET::SSLSocket::Listen() method opens a socket to listen for incoming requests.
- Peek Method
The INET::SSLSocket::Peek() method reads characters into a string. Peek does not remove the characters from the receive buffer.
- Query_TCP Method
Returns .T. (TRUE) if the TCP connection described by the arguments matches an active connection.
- Read Method
The INET::SSLSocket::Read() method reads characters from the connection into a string.
- ReadBinary Method
The INET::SSLSocket::ReadBinary() method reads bytes from the connection into a BLOB variable.
- ReadLine Method
The INET::SSLSocket::ReadLine() method reads a line from the receive buffer. A line is terminated by a CR-LF. If nothing is available, the method returns an empty string.
- ReadUntil Method
Reads from the input stream until the delimiter is encountered or a timeout occurs. If the function returns false, there may still be data in the returned buffer. This means that the read timed out before receiving the delimiter. If ReturnDelimiter is true, the delimiter is returned with the string.
- Reconnect Method
The INET::SSLSocket::Reconnect() method reestablishes the connection with an SSL partner (session settings may have changed).
- SendFile Method
The INET::SSLSocket::SendFile() method sends the named file.
- SetOptions Method
The INET::SSLSocket::SetOptions() methods sets one or more options in a single call.
- StartSSLSession Method
The INET::Socket OpenSocket method begins an SSL session with a socket that is already opened. If successful the socket remains secure until closed. If unsuccessful both sockets will be closed. After this call you should no long reference OpenSocket.
- Write Method
The INET::SSLSocket::Write() method writes character data to the connection.
- WriteBinary Method
The INET::SSLSocket::WriteBinary() method writes binary data to the connection.