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

problem with an XmlTextReader with a NetworkStream

I've got a multi-threaded server (we are very early in the project,
trying to uncover some risks), and I want to send data using XML.

The class ServerAdapter is supposed to connect to the server (which
works fine), to send data, but on the same stream be able to read
data (which is causing problems).

In the function "bool Connect()", we want to instantiate the
XmlTextReader with the stream that we got from the 'TcpClient
client', but somehow that goes wrong. No exception is cast, but the
problem definately has something to do with the stream that we get
from the call 'client.GetStream()'.
When we try to do the exact same thing, with a stream NOT from a
TcpClient, there is no problem. We've checked to see if it had
something to do with the access-property on the connection (the
'Socket') on the serverside, but it came up negative. I am pretty
much out of ideas, so if you can help me out, it'd be great (first
time here, so I dont know the standarts) :)

We've checked how far it gets with text-outputs, so we KNOW that the
XmlTextReader causes the problem.

Here is the part of code that fails.

public class ServerAdapter : IServerAdapter
{
private IServerEventHandler serverEventHandler;

private TcpClient client;
private NetworkStream stream;

private Thread readThread;

private XmlTextReader streamReader;
private XmlTextWriter streamWriter;
private BinaryReader reader;

private XmlValidatingReader validatingReader;
private XmlSchemaCollection schemaCollection;

public ServerAdapter()
{

}

public ServerAdapter( IServerEventHandler serverEventHandler ):base()
{
this.serverEventHandler = serverEventHandler;

}

public bool Connect()
{
bool connected = false;

try
{
client = new TcpClient();
client.Connect( "10.0.55.12", 4312 );

stream = client.GetStream();

streamReader = new XmlTextReader( stream );

streamWriter = new XmlTextWriter( stream, new
System.Text.UTF8Encoding() );

blablabla....

Thanks in advance

...Borgbjerg
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 15 '05 #1
1 2495
Borgbjerg <dm******@mail.ikasths-dot-dk.no-spam.invalid> wrote:
I've got a multi-threaded server (we are very early in the project,
trying to uncover some risks), and I want to send data using XML.

The class ServerAdapter is supposed to connect to the server (which
works fine), to send data, but on the same stream be able to read
data (which is causing problems).

In the function "bool Connect()", we want to instantiate the
XmlTextReader with the stream that we got from the 'TcpClient
client', but somehow that goes wrong. No exception is cast, but the
problem definately has something to do with the stream that we get
from the call 'client.GetStream()'.
When we try to do the exact same thing, with a stream NOT from a
TcpClient, there is no problem. We've checked to see if it had
something to do with the access-property on the connection (the
'Socket') on the serverside, but it came up negative. I am pretty
much out of ideas, so if you can help me out, it'd be great (first
time here, so I dont know the standarts) :)


I've seen this before, and I believe it's a bug in XmlTextReader which
assumes it will have a large "chunk" of data to read to start with.

Have a look at

http://groups.google.com/groups?thre...07dfd57989867%
40msnews.microsoft.com

(aka http://tinyurl.com/347dh)

for more details.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2

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

Similar topics

2
by: Ayende Rahien | last post by:
I've a problem in my code using NetworkStream. I've a server which listen to a port, and then Read() from it, and a client that send data. My NetworkStream is wrapped in a CryptoStream, and my...
1
by: cmjman | last post by:
I have an issue where networkStream.Write doesn't perform its write downstream from my client program until the network stream is closed. I then see the data that was sent appear on the other side....
2
by: Theo | last post by:
Hi, I am using a tcpclient and a tcplistener to send and receive packets. The client sends a packet and the listener replies with another one. I can send 2 packets and get an answer from the...
2
by: David Dvali | last post by:
Hello. I wnat to read some data from server, I'm using following code: ---------------------------------------------------------------------------------------- TcpClient cl = new TcpClient();...
12
by: Brian Henry | last post by:
I wrote a simple client / server app (nothing major, just sends text) it works fine locally on the same system, but once i move the client to a remote system it errors and gives me "No connection...
0
by: Harley | last post by:
Hello, I am just learning the tcp/ip functions etc under vb.net so please look over me if this is obviouse. I have been all over looking into any functions that I didn't totaly understand and...
0
by: Tim Wagaman | last post by:
I an having issuses with a loop I am running to keep checking for messages coming across our line. The goal: Listen for messages on port 5001 and print the messages into a text file. The port...
4
by: Tom Shelton | last post by:
Problem: XmlTextReader Constructor hangs until underlying socket closes when passed a NetworkStream. Example: Dim reader As New XmlTextReader (New NetworkStream(s, False)) I can...
7
by: littleIO | last post by:
Hi, I'm stuck on a very simple problem and just cant seem to get around it, little help would be much appreciated. I have a server which listens, receives calls, processes them and sends back the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
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.