Hi,
I am writing to a network stream using the following code:
TcpClient client = new TcpClient();
client.Connect( IPAddress.Parse ("192.168.2.100 "), 55650);
NetworkStream stream = client.GetStrea m();
StreamWriter writer = new StreamWriter(st ream);
writer.Write("T EST");
writer.Flush();
Now, I am reading from the network stream using the following code:
NetworkStream netStrm = new NetworkStream(s ocket);
StreamReader reader = new StreamReader(ne tStrm);
string str = reader.ReadToEn d();
The method ReadToEnd(), is blocking the client application is
terminated. I also tried to client.Close(), but still method blocks.
Is there a way to read all data sent without terminating the client.
Can someone help me out
Thanks in Advance 3 10760
<be*********@ya hoo.com> wrote: I am writing to a network stream using the following code:
TcpClient client = new TcpClient(); client.Connect( IPAddress.Parse ("192.168.2.100 "), 55650); NetworkStream stream = client.GetStrea m(); StreamWriter writer = new StreamWriter(st ream); writer.Write("T EST"); writer.Flush();
Now, I am reading from the network stream using the following code:
NetworkStream netStrm = new NetworkStream(s ocket); StreamReader reader = new StreamReader(ne tStrm); string str = reader.ReadToEn d();
The method ReadToEnd(), is blocking the client application is terminated. I also tried to client.Close(), but still method blocks.
Is there a way to read all data sent without terminating the client.
No - there's no real sense of "all data" until the stream has been
closed, because the server could always have sent some more since you
thought you'd got it all.
If you're able to design the protocol yourself, it's a *really* good
idea to state how much data you're going to send before you send it
wherever there's a variable amount.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too be*********@yah oo.com wrote: Hi,
I am writing to a network stream using the following code:
TcpClient client = new TcpClient(); client.Connect( IPAddress.Parse ("192.168.2.100 "), 55650); NetworkStream stream = client.GetStrea m(); StreamWriter writer = new StreamWriter(st ream); writer.Write("T EST"); writer.Flush();
Now, I am reading from the network stream using the following code:
NetworkStream netStrm = new NetworkStream(s ocket); StreamReader reader = new StreamReader(ne tStrm); string str = reader.ReadToEn d();
The method ReadToEnd(), is blocking the client application is terminated. I also tried to client.Close(), but still method blocks.
Is there a way to read all data sent without terminating the client.
Can someone help me out Thanks in Advance
Have you looked into the Asynchronous methods such as BeginRead,
BeginWrite etc...? Thes operations are executed on a background thread
and shouldn't block the apps main thread.
--
Rob Schieber
client.shutdown (send) (or shutdown(both) ) from the client will unblock
server blocking read and read will return 0. Even if you "packetize" your
stream with pre-pended len bytes, you most likely need to do this anyway to
signal to the server that your not sending any more messages.
--
William Stacey [MVP]
<be*********@ya hoo.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. . Hi,
I am writing to a network stream using the following code:
TcpClient client = new TcpClient(); client.Connect( IPAddress.Parse ("192.168.2.100 "), 55650); NetworkStream stream = client.GetStrea m(); StreamWriter writer = new StreamWriter(st ream); writer.Write("T EST"); writer.Flush();
Now, I am reading from the network stream using the following code:
NetworkStream netStrm = new NetworkStream(s ocket); StreamReader reader = new StreamReader(ne tStrm); string str = reader.ReadToEn d();
The method ReadToEnd(), is blocking the client application is terminated. I also tried to client.Close(), but still method blocks.
Is there a way to read all data sent without terminating the client.
Can someone help me out Thanks in Advance This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hal |
last post by:
I am experiencing blocking problems on SQL Server 2000, SP3a. I have
read the posts and set up a job SQL agent to report on these
occurences I save the results to a table before executing an sp to
kill the offending process id. I am puzzled as to how a process that
does no updating can be guilty of blocking. Typically, I think what
is happening is a process that does no updates is blocking processes
that are trying to do updates. Can...
|
by: David Sworder |
last post by:
This message was already cross-posted to C# and ADO.NET, but I forgot to
post to this "general" group... sorry about that. It just occured to me
after my first post that the "general" group readers might have some
thoughts on this perplexing .NET blocking issue.
(see below)
=====
Hi,
|
by: Mario |
last post by:
Hello,
I couldn't find a solution to the following problem (tried
google and dejanews), maybe I'm using the wrong keywords?
Is there a way to open a file (a linux fifo pipe actually) in
nonblocking mode in c++? I did something ugly like
--- c/c++ mixture ---
mkfifo( "testpipe", 777);
|
by: Michi Henning |
last post by:
Hi,
I'm using a non-blocking connect to connect to a server.
Works fine -- the server gets and accepts the connection.
However, once the connection is established, I cannot
retrieve either the local or the remote endpoint from
the client-side socket.
The *really* strange thing is that Socket.LocalEndPoint is null.
According to the doc, that's impossible: reading the LocalEndPoint
|
by: Nad |
last post by:
Hello All,
I have been trying to get some sort of documantion on how
StreamReader.ReadToEnd() finds out if the stream has ended and if
anyone can read the following lines and tell me how to control
indefinite blocking issue. these are from MSDN.
"ReadToEnd assumes that the stream knows when it has reached an end.
For interactive protocols, in which the server sends data only when
you ask for it and does not close the connection,...
| |
by: loosecannon_1 |
last post by:
I get a 90-120 second blocking when send 15 or so simultaneous queries
to SQL Server 2000 that query a view made up of two joined tables.
After each query is blocking for the same amount of time they all
return. Further identical queries of this type work in 3-4 seconds
(caching?) until hours later where it happens again. If I query the
tables directly (without the view) I still get the same blocking. If I
remove the join (it is a simple...
|
by: Chris S. |
last post by:
I'm curious - does StreamReader.ReadToEnd() handle chunk loading of
data or does it block until the whole stream is loaded? I've been use
to handling the buffer myself but I'm thinking maybe this is a quicker
way of doing it. In particular I want to ensure the UI doesn't hang
whilst loading, for example on a progress bar.
Thanks
|
by: opi |
last post by:
My blocking TCP server hangs in the Accept method when the client
software sometimes gets an error. Are there any ways to stop this
blocking in the Accept method so I dont have to restart the server?
I would rather not use threading or non-blocking sockets.
Using VB.Net 2005.
|
by: puzzlecracker |
last post by:
is it even possible or/and there is a better alternative to accept
input in a nonblocking manner?
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |