473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Error when trying to use StreamReader to read from a NetworkStream

Hey,

Has anyone ever got a "Unable to read data from transport connected" message
after reading data from a streamreader composed of a networkstream.

For example:

Server

TcpListener tcpServer = new TcpListener(localAddr,port);

TcpClient tcpClient = new TcpClient()
tcpClient = tcpServer.AcceptTcpClient();

NetworkStream networkStream = tcpClient.GetStream();

StreamWriter stringWriter = new StringWriter(networStream);

string lstrData = "An XML string"; // this is really a xml string
stringWriter.WriteLine(lstrData);
stringWriter.Flush();

-----------------------------
Client
--------

TcpClient tcpClient = new TcpClient("localhost",port);

NetworkStream networkStream = tcpClient.GetStream();

StreamReader streamReader = new StreamReader(networkStream);
string strData = streamReader.ReadLine();

-----------------------------------------------

When debugging networkStream is readable and has dada available, but
streamReader.ReadLine() returns the above error message: "Unable to read
data from transport connected".

BTW, the Server is sending the data fine, it's just the client that's not
reading fromt he stream.

Does anyone have any ideas of what I might be doing wrong here?

Much thanks in advance,

--
Al
May 13 '06 #1
0 1318

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

Similar topics

4
by: Astronomically Confused | last post by:
using System; using System.Collections; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; class HttpProcessor { private Socket s;
2
by: Keith Kingsley | last post by:
I'm using a StreamReader to read in several lines from an ASCII file. I'd like to know the StreamReader's "true" position-- that is, the number of bytes into the file that the StreamReader has...
1
by: Rob T | last post by:
Hi, I have a simple little program that I'm going to use to access our SMTP server. The below code works perfectly fine, but my question is if I were to try to execute the last line...
2
by: Al Wilkerson | last post by:
Hey, Has anyone ever got a "Unable to read data from transport connected" message after reading data from a streamreader composed of a networkstream. For example: Server TcpListener...
0
by: Brent | last post by:
After six months flawless operation, I'm suddenly getting this error: "Unable to read data from the transport connection." The code* hasn't changed, and from what I can see, neither have the IP...
6
by: kikapu | last post by:
Hi to all, i have the following simple Socket Server code and a vb client that send to it some data using WinHttp. (very simple code, just open and send) The string is succesfully sent to the...
2
by: White Spirit | last post by:
I have a function within an application where a client connected to a server continuously sends data. The code on the server side is of the following form: Socket socket = receiveSocket;...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
0
by: id10t error | last post by:
Hello, I am trying to write soem code that will send data to an Oneil printer over our network. I know the printer works and is setup correctly because I can print to it from there software. In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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...
0
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
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...

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.