473,566 Members | 2,847 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 2402
"Charles" <Ch*****@discus sions.microsoft .comwrote in message
news:9C******** *************** ***********@mic rosoft.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
2376
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 & TCPClient connection from the Server to the PDA. The connection allows me to Send from the PDA to the Server - but the PDA will not read what the...
4
7189
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 one of these things and it WON'T read data. If I set a breakpoint in my EndRead callback, it never goes off. NOTHING is different from anywhere...
1
2629
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 "unable to write data to transport connection" error. I have tried multiple ways to transfer this file(including remoting, sockets without network...
2
2588
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(); ImagePictureBox.Image.Save(nstream,System.Drawing.Imaging.ImageFormat.Jpeg); nstream.Close(); If I don't close the underlying socket with...
6
3315
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 data. The
2
1819
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 reverse. I'd appreciate any help. Server ------ Dim TcpC as New TcpListener(IPAddress.Parse("192.168.1.5"), 8500) TcpC.Start()
5
4213
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 release... Is there anyone out there that considers themselves a threading / sockets / serialization guru? Not sure if it's appropriate to post an...
3
11027
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 i run the program).....but when i watch the transfering of bytes by debuging it.(RED dot on while(nfs.CanRead) )..it shows that complete bytes are...
6
7261
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 remember there are 2 streams in Java, one for read, one for write. If I just use synchronous Read() and Write() method:
0
7666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6260
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
925
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.