TcpClient Notification of sent data

  • Thread starter Thread starter Adie
  • Start date Start date
A

Adie

I'm using TcpClient in blocking mode with NetworkStreams and would like to
be able to give notification that data was sent - I presume this must be
possible? But anyone know how?
 
Hi,

You need to be more especific about what you want to do.

you can send it after sending the data, like

tcpclient.GetStream().Write( ... )
sendnotification () ;


as I said before, be more especific about what you are trying to do.

cheers,
 
In blocking mode you set TcpClient.NoDelay = true and then you assume that
after each call to NetworkStream.Write the data is actually sent. BTW, use a
large enough buffer because NetworkStream.Write, on the contrary to
Socket.Send, doesn´t return the number of bytes actually sent to perform a
loop if needed until all data is sent. Also, notice that
NetworkStream.Flush() has no effect in the current implementation because
NetworkStream is not buffered.

Other approach if you really want notification is to switch to non-blocking
mode and use asynchronous methods NetworkStream.BeginWrite and
NetworkStream.EndWrite, which encapsulate internally asynchronous methods
Socket.BeginSend, Socket.EndSend.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 
Carlos said:
In blocking mode you set TcpClient.NoDelay = true and then you assume that
after each call to NetworkStream.Write the data is actually sent. BTW, use a
large enough buffer because NetworkStream.Write, on the contrary to
Socket.Send, doesn´t return the number of bytes actually sent to perform a
loop if needed until all data is sent. Also, notice that
NetworkStream.Flush() has no effect in the current implementation because
NetworkStream is not buffered.

Ok, NoDelay sounds worth a try.
Other approach if you really want notification is to switch to non-blocking
mode and use asynchronous methods NetworkStream.BeginWrite and
NetworkStream.EndWrite, which encapsulate internally asynchronous methods
Socket.BeginSend, Socket.EndSend.

Yes, Ive looked at the asyn methods, can't make my mind up yet which to
use, blocking or not, I'll play around a bit more and see which fits the
bill.

Thanks.
 
Back
Top