last day (14 days later) » 

8:11 AM
Hello
Im Royi 36 , Israel , and I saw one of your answer here : stackoverflow.com/a/5654359/859154
Is it possible to ask small question regarding STREAMS ?
 
you can try :)
 
Ok :-)
when writing to streams :
I sometimes see this pattern :
 while (true)
    {
        int read = input.Read (buffer, 0, buffer.Length);
        if (read <= 0)
            return;
        output.Write (buffer, 0, read);
    }
 
yup. that's synchronous read/write. Stream.CopyTo didn't exist before C# v4 (IIRC)
 
but how does the other side ( who reads) knows - that there is no more data ?
-
 
It doesn't, it will just block until you close the stream, signalling EOF
 
8:14 AM
you mean ` networkStream.Flush();` ?
 
Nope, that just flushes.
So you are sending to a network stream.
It's called synchronous because Read blocks until (1.) data arrives or (2.) end of stream is detected
For network streams it's traditionally hard to detect end of stream, especially when e.g. the connection is dropped. This is why all network reads usually are done
(a) blocking with a timeout
(b) non-blocking (asynchronous), where the timeout is externally measured
 
im an asp.net developer for many years and know the importance and does use async await for ( IO operations)
 
good :)
 
but does waiting for socket to get data can be done asynchruounsly ?
 
of course
 
8:17 AM
without tie a thread while listening ?
I tell you why i ask
 
I reckon. It's been a while since I did this in c#, but I don't see why not.
 
all examples I saw for asynchounse sockets - shows a main thread which open a new thread for each client
hence they call it async....
but the thread is WAITING !
blocking
so i dont see where is the async part here ( async = asynchronous shortcut word for me)
 
Slightly related:
14
Q: Difference between StreamReader.Read and StreamReader.ReadBlock

J MThe documentation simply says ReadBlock is "a blocking version of Read" but what does that mean? Someone else has asked the question before but, huh? http://www.pcreview.co.uk/forums/thread-1385785.php The guy answering said Basically, it means that you can rely on StreamReader.ReadBloc...

@RoyiNamir yeah, that's bad naming then. It's blocking IO with thread concurrency
 
yes becuase async doesnt require parallism
so - does a socket can not tie a thread while listening (no data) ?
 
@RoyiNamir ^ there's an answer from MSDN
 
8:21 AM
please notice : "so execution of the client application is not suspended while the server returns a response".
they dont talk about idle while listening !
 
@RoyiNamir where should I notice this?
 
msdn link you sent
 
@RoyiNamir You don't listen while typing exclamation mark !
In that example all they do is wait for an event to avoid running the same async operation simultaneously on a single socket
 
Yes , bUt while waiting for data , is there a thread blocked while there is not data to fetch ?
they use WaitOne
 
Why don't you look at it? You've repeated the question ~5x now, almost always beginning with some variation of "Yes, but...". If I cannot reassure you enough, please look for yourself
5 mins ago, by sehe
This is Async client: http://msdn.microsoft.com/en-us/library/bew39x2a(v=vs.110).aspx
I'll move on now. Work calls :)
 
8:25 AM
ok thank you
 

last day (14 days later) »