title: Issues Sending messages with TCPClient in vb.net
body: <p>I'm realizing a .NET chat application but i still have that error:
  I can send only a message per connection.
  For example. With the code below, i can send only one message that can be received correctly by the other peer, but if i send another message message, on the same connection,it won't be received by the remote PC.
  Here is the code:</p>
  
  <pre><code>Dim client_TCP As New TcpClient
  Private Sub send_obj(ByVal obj As Object)
      Dim bf As New BinaryFormatter
      Dim tosend As Packet
  
      tosend.data = obj
      bf.Serialize(client_TCP.GetStream(), tosend)
      client_TCP.GetStream.Flush()
  End Sub
  Private Sub connect_to_port()
      Try
          client_TCP = New TcpClient(client_data.getIP(), client_data.getPort())
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  
  End Sub
  Private Sub disconnect_from_port()
      client_TCP.Close()
  End Sub
  </code></pre>
  
  <p>And here is the listener:</p>
  
  <pre><code>Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer.Tick
      If client_TCP_listener.Pending = True Then
  
          ....
      End If
  End Sub
  </code></pre>
  
  <p>So, to send a message I always need to do this (example):</p>
  
  <pre><code>    Dim b As Byte
      b = 1
      disconnect_from_port()
      connect_to_port()
      client_TCP.GetStream().WriteByte(b)
      client_TCP.GetStream().Flush()
  </code></pre>
  
  <p>I tried to put\remove the flush from both the code. Nothing happened.
  Have you got any ideas?!</p>