Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello I'm starting to learn Server Client Application in VB.NET. This tutorial is what I have searched https://www.youtube.com/watch?v=MSiBbtxWpI8[^]

But my ReadLine is paused when opening the client application
VB
Private Sub Listening()
    Do Until Not IsListening
        If Server.Pending Then
            Client = Server.AcceptTcpClient
            ClientData = New IO.StreamReader(Client.GetStream)
        End If
        Try
            RaiseEvent MessageReceived(Me, ClientData.ReadLine) 'PAUSE
        Catch ex As Exception
            RaiseEvent MessageReceived(Me, "Error")
        End Try
        Threading.Thread.Sleep(100)
    Loop
End Sub

First, I have tried reworking this using Timer or Backgroundworker same happens. So I copy the code shown on tutorial but unable to run properly.

Please Help.. Thanks
Posted

1 solution

Well yes - it will do.
ReadLine is what is called a "blocking" operation: it does not return until the stream provides a complete line of data (terminated by a newline) or it reaches the end of the stream.
If ReadLine hangs, then it is waiting for the other end of the TCP connection to send a new line character or sequence.

Check the other end first: if that looks OK, try reading character by character and see if you get anything at all...
 
Share this answer
 
Comments
hansoctantan 4-Sep-14 13:33pm    
thank you very much, the problem is its not the server its the client
DataStream.Write("OK")
DataStream.Flush()
Don't have a vbnewLine added on the Write command
OriginalGriff 4-Sep-14 14:03pm    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900