TcpClient & TcpListener

bungpeng

Senior Contributor
Joined
Sep 10, 2002
Messages
906
Location
Malaysia
I create 2 simple applications from TcpClient and TcpListener classes, my purpose is to communicate between 2 application for data sharing.

My problem is that, when I send message from TcpClient to TcpListener, my TcpListener application will do some process and send the "completed" message back to TcpClient. So how do I received this message from TcpClient?

Visual Basic:
        Dim Client As TcpClient
        ......

        Client.GetStream().Write(Buffer, 0, Buffer.Length)

        While Not Client.GetStream.DataAvailable()
            Application.DoEvents()
        End While

        If Client.GetStream.DataAvailable() Then
            ......
        End If

If I use above example, the "While Not Client.GetStream.DataAvailable()" process will make the server slow. I did tried to use Timer instead, but it seem to no working, about other ideas?

Thank you
 
I forget exactly where but on Microsoft's site if you search this topic you'll find a downloadable project in vb.net regarding a tcplistener/client/server app. It's really helpful for this type of programming - it's by that Lahothka(sp?) dude
 
Back
Top