468,140 Members | 1,437 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,140 developers. It's quick & easy.

TcpClient Notification of sent data

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?
Nov 16 '05 #1
3 2296
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Adie" <us****@dont-listen.net> wrote in message
news:1g****************@dont-listen.net...
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?

Nov 16 '05 #2
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
"Adie" <us****@dont-listen.net> escribió en el mensaje
news:1g****************@dont-listen.net...
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?

Nov 16 '05 #3
Carlos J. Quintero [.NET MVP] wrote:
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.
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by מורדי | last post: by
5 posts views Thread by Jeff Weber | last post: by
2 posts views Thread by Noozer | last post: by
2 posts views Thread by Mythran | last post: by
1 post views Thread by Frank | last post: by
1 post views Thread by Frank | last post: by
2 posts views Thread by DrZoop | last post: by
reply views Thread by zhangke007 | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.