TLSInputStream
class TLSInputStream : WrappedInputStream, TlsSessionDelegate
This class is TLS encrypted input stream.
-
The TLS session
Declaration
Swift
let session: TlsSession
-
A buffer of data, that have been read.
Declaration
Swift
var buffer: Data
-
The index pointing at a position in the buffer. This avoids moving around and re-allocating the buffer.
Declaration
Swift
var bufferIdx: Int
-
The status of the stream.
Declaration
Swift
var status: Stream.Status
-
An error that might have occurred.
Declaration
Swift
var error: Error?
-
Return the wrapped input stream.
Declaration
Swift
override var stream: WrappedInputStream { get }
-
Initialize a TLS encrypted input stream with a given TLS session.
Declaration
Swift
init(_ stream: WrappedInputStream, withSession session: TlsSession)
Parameters
stream
The wrapped input stream.
session
The TLS session.
-
Returns the size of the internal TLS buffer. Not to be confused with
buffer
.Declaration
Swift
var internalTlsBufferSize: Int { get }
-
Get the status for the stream.
Declaration
Swift
override var streamStatus: Stream.Status { get }
-
Get the error for the stream.
Declaration
Swift
override var streamError: Error? { get }
-
Open the stream. The stream will actually open after the TLS handshake is completed.
See
Stream.open()
Declaration
Swift
override func open()
-
Close the stream.
See
Stream.close()
Declaration
Swift
override func close()
-
Get a property for a given key. This is a no-op and does nothing.
Declaration
Swift
override func property(forKey key: Stream.PropertyKey) -> Any?
Parameters
key
The name of the property.
Return Value
This always returns
nil
. -
Set a property for a given key to a given value. This is a no-op and does nothing.
Declaration
Swift
override func setProperty(_ property: Any?, forKey key: Stream.PropertyKey) -> Bool
Parameters
property
The value of the property.
key
The name of the property.
Return Value
This always returns
false
.
-
Indicates whether bytes are available on the wrapped input stream.
Declaration
Swift
override var hasBytesAvailable: Bool { get }
-
Read bytes from the wrapped input stream. This will decrypt the data.
Declaration
Swift
override func read(_ dataPtr: UnsafeMutablePointer<UInt8>, maxLength: Int) -> Int
Parameters
dataPtr
A pointer to the buffer, to which the bytes should be read.
maxLength
The maximum lenghts of bytes to be read.
Return Value
The amount of bytes actually read.
-
Get the buffer of the wrapped input stream. This is a no-op and does nothing.
Declaration
Swift
override func getBuffer(_ buffer: UnsafeMutablePointer<UnsafeMutablePointer<UInt8>?>, length len: UnsafeMutablePointer<Int>) -> Bool
Parameters
buffer
A pointer to the buffer.
length
A pointer to a number, where the length of the buffer will be stored.
Return Value
This always returns
false
.
-
Delegate function for the wrapped stream.
Declaration
Swift
override func stream(_ aStream: Stream, handle eventCode: Stream.Event)
Parameters
aStream
The stream calling the delegate. Has to be the wrapped input stream.
eventCode
The event that occurred.
-
This function is called, once a TLS session was established, i.e., after the TLS handshake was successfully performed. It indicates that the implementing stream’s state can be set to
open
.Declaration
Swift
func finishOpen()
-
This function is called, once an error occurs.
Declaration
Swift
func setError(_ error: TlsStreamError)