Hi. I have the following code. I want to read the entire message instead of reading it char by char. How would i do this? Im thinking along the lines of Reader.ReadToEnd(). But Im having a hard time implementing such a feature.
Thanks
Code:Imports System.Net.Sockets Imports System.Threading Imports System.IO Imports System.Net Class Window1 Dim Listener As New TcpListener(65535) Dim Client As New TcpClient Dim Message As String = "" Private Sub StartServerButton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles StartServerButton.Click Dim ListThread As New Thread(New ThreadStart(AddressOf Listening)) ListThread.Start() End Sub Private Sub Listening() Listener.Start() While Listener.Pending = False Message = "" Client = Listener.AcceptTcpClient() Dim Reader As New StreamReader(Client.GetStream()) While Reader.Peek > -1 Message = Message + Convert.ToChar(Reader.Read()).ToString End While MsgBox(Message, MsgBoxStyle.OkOnly) End While End Sub End Class




. I have the following code. I want to read the entire message instead of reading it char by char. How would i do this? Im thinking along the lines of Reader.ReadToEnd(). But Im having a hard time implementing such a feature.
Reply With Quote