473,503 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NetworkStream Read/Write operations - # bytes read/written.

Hi,

Is there a way to find out how many bytes NetworkStream Read/Write actually
read/wrote when there is an exception (i.e. socket read/write timeout). Or,
can I assume that if there is an exception that no bytes are read/written.

Thanks,
Charles.
Nov 23 '06 #1
1 2387
"Charles" <Ch*****@discussions.microsoft.comwrote in message
news:9C**********************************@microsof t.com...
Is there a way to find out how many bytes NetworkStream Read/Write
actually
read/wrote when there is an exception (i.e. socket read/write timeout).
For reading, if you don't have a successful call to a receiving function,
you cannot safely expect there to be any data at all.

For writing, the best you can do is have something in your application
protocol in which the recipient can tell you how many bytes it received.
That's not exactly the same as how many bytes are written, but it's the best
you can do. If your application protocol has no way to report the bytes
received at the other end, then you have to assume that the entire write
failed.

Pete
Nov 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2361
by: Dustin B | last post by:
Since this issue encompasses so many things - I have to generally post it I guess. I'm building an application for a Wireless PDA - when it is connected to the Network I tested a TCPListener &...
4
7170
by: 0to60 | last post by:
I have a class that wraps a TcpClient object and manages all the async reading of the socket. It works really nice, and I use it all over the place. But there's this ONE INSTANCE where I create...
1
2617
by: kmacintyre | last post by:
I am trying to us a simple NetworkStream to transfer a file over tcp. This works most of the time, but one specific file never downloads(.mdb file). It seems to close the socket and I get an...
2
2584
by: Nuno Magalhaes | last post by:
In a simple code I do something like this in a synchronous connection: -*server*----------------------------- ClientTcp=ListenerTcp.AcceptTcpClient(); NetworkStream nstream=ClientTcp.GetStream();...
6
3306
by: Ryan | last post by:
Hi, I am confused with how NetworkStream works. My application needs to handle heavy requests sent through TCP socket connection. I use NetworkStream.Read method to get the stream...
2
1815
by: Dustin Brisebois via DotNetMonster.com | last post by:
This is coming from a Windows 2003 Server to a HP Pocket PC (WinCE 2003) over 802.11b. The device is on the Network and can be pinged, it can write data to the Server stream - but not read the...
5
4208
by: | last post by:
I've got a basic "chat" infrastructure that can send objects across the wire, but I'm running into a few issues with trying to send multiple messages and things behaving differently in debug and...
3
11022
by: shahla.saeed | last post by:
hi, plzz check my code and let me know where the problem is lying...becuase whenever i try to tansfer the file of 573KB(mp3) it just tranfer few Kb of file(Somtimes 5.2Kb,somtimes 32Kb..every time...
6
7249
by: Ryan Liu | last post by:
Hi, I have some basic question about NetworkStream, can someone explain to me? Thanks a lot in advance! TcpClient has a GetStream() method return a NetworkStream for read and write. I...
0
7198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.