本文整理汇总了VB.NET中System.Net.Security.SslStream.Read方法的典型用法代码示例。如果您正苦于以下问题:VB.NET SslStream.Read方法的具体用法?VB.NET SslStream.Read怎么用?VB.NET SslStream.Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Security.SslStream
的用法示例。
在下文中一共展示了SslStream.Read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: ReadMessage
Private Shared Function ReadMessage(sslStream As SslStream) As String
' Read the message sent by the server.
' The end of the message is signaled using the "<EOF>" marker.
Dim buffer = New Byte(2048) {}
Dim messageData = New StringBuilder()
Dim bytes As Integer
Do
bytes = sslStream.Read(buffer, 0, buffer.Length)
' Use Decoder class to convert from bytes to UTF8
' in case a character spans two buffers.
Dim decoder As Decoder = Encoding.UTF8.GetDecoder()
Dim chars = New Char(decoder.GetCharCount(buffer, 0, bytes) - 1) {}
decoder.GetChars(buffer, 0, bytes, chars, 0)
messageData.Append(chars)
' Check for EOF.
If messageData.ToString().IndexOf("<EOF>") <> -1 Then Exit Do
Loop While bytes <> 0
Return messageData.ToString()
End Function