Hi,
I have TCPIP connection using TCPclient and TCPlistener in a seperate thread.
It works fine if I allways open a new client after each roundtrip (sending /recieving or recieving /sending).
I wonder how I could keep the connection open and constantly exchange data.
server side
Code:
while true
 While not server.pending
 end while

 dim client as TcpClient = server.AcceptTcpClient()
 Dim stream as NetworkStream = client.GetStream()
 ...get the data  and send out new data in msg...
 stream.Write(msg.0,msg.Length)
 client.Close()
end while
Client
Code:
Dim client As New TcpClient(IP,Port)
dim stream as NetworkStream= client.GetStream()
..prepare data...
stream.write(data,0,data.Length)
'Get the requested data
While Not stream.DataAvailble
 Sleep(200)
End While
While stream.DataAvailable
   Dim bytes As Int32 = stream.Read(readbuffer, 0, readbuffer.Length)
   responseData += System.Text.Encoding.ASCII.GetString(readbuffer, 0, bytes) 
End While

stream.Close():client.Close()
client = New TcpClient(IP,Port)
data = System.Text.Encoding.ASCII.GetBytes("some Text")
stream=client.getStream()
stream.write(data,0,data.Length)