473,385 Members | 1,757 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,385 software developers and data experts.

Why data is not available in network stream?

server side coding

Expand|Select|Wrap|Line Numbers
  1.  TcpClient dupClient = listener.AcceptTcpClient();
  2.  NetworkStream ns = dupClient.GetStream();
  3.  StreamReader sr = new StreamReader(ns);
  4.  StreamWriter sw = new StreamWriter(ns);
  5.  sw.WriteLine("send");
  6.  string da = sr.ReadLine();
client side coding

Expand|Select|Wrap|Line Numbers
  1. NetworkStream ns = client.GetStream();
  2.  StreamReader sr = new StreamReader(ns);
  3.  StreamWriter sw = new StreamWriter(ns);
  4.  if(ns.DataAvailable)
  5.  {
  6.   da = sr.ReadLine();
  7.  }
  8.  sw.WriteLine(folder.ToString() + filename.ToString());
Here the server writes the data and waits for reading
but the data is not available on the stream in client side.Why the data sent by server is not available in network stream of client?
Jan 3 '11 #1
0 1135

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John | last post by:
I have a Socket open to a target system. I get the network stream from the open socket and then create a stream reader and stream writer on this stream. The stream reader and writers are operating...
2
by: Kueishiong Tu | last post by:
I have a network stream which I got from HttpWebResponse and does not support seeking, How do I find the length of the network stream? HttpWebResponse* response = dynamic_cast<HttpWebResponse*>...
6
by: Yechezkal Gutfreund | last post by:
I have been using the following code (successfully) to read Xml formated text packets from a TCP stream. The output from the server stream consists of a sequence of well formed Xml documents...
5
by: cs | last post by:
I need to get the position and also seek in a network stream, is there an easy way to do that? (I am converting some java code so thats the easy path).
8
by: Scott | last post by:
Hi guys, If I try to call read(), readline(), readtoend() and there is nothing to read (from a never ending loop for example) the program seems to continue but it exits the loop for no apparent...
7
by: simonrigby_uk | last post by:
Hi all, Sorry if this is the incorrect group but I couldn't see anything directly relevant. Can someone confirm for me what happens when two network streams are sent to an application at the...
3
by: Alex Clark | last post by:
Hi All, I'm having some problems reading a network stream. I'm writing a lightweight POP client to handle a very specific task, but I keep unexpectedly reaching the end of the datastream when...
3
by: kjell | last post by:
Hi, I'm trying to write a program that reads data from a network stream. I would like the program to read all available data in the buffer and then process the data. I do not want the program...
3
by: markclinn | last post by:
I have a device in the field that I access by the stream method. I open the Stream and do the following: 1. stream.write a character to the device. 2. stream.read the information from the...
3
by: Al G | last post by:
Does anyone know what a -1 means as a Network stream read timeout? Console.WriteLine("Timeout= {0}", stream.ReadTimeout) returns a -1 Thanks
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...

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.