stream associate with socket; will one end block another

R

Ryan Liu

Hi,

As I remember theare are In and Out stream associate with a socket.
TcpClient seems there in only one NetworkStream to do both read and write.

Then will it be a conflicit if both side try to send data?

And when one end is sending data, if another end is not calling Recevive or
BeginReceive, will the sender be blocked? Or recevier side network hardware
will read anyway, just our high-end application has not take the data yet?

BTW, if one side use sychronous/asychronous way to receive and send, the
anthoer side does not have to be same, right?

Thanks a lot!
Ryan
 
W

William Stacey [C# MVP]

| As I remember theare are In and Out stream associate with a socket.
| TcpClient seems there in only one NetworkStream to do both read and write.

TCP is a implicit stream. .Net can suface that stream with the
NetworkStream Stream class, however you don't have to use it and can use raw
read/write methods on the socket.

| Then will it be a conflicit if both side try to send data?

Not really. But it could be a problem if your application protocol does not
expect that.

| And when one end is sending data, if another end is not calling Recevive
or
| BeginReceive, will the sender be blocked?

No. Both sides can send or receive at same time. If one side does not take
data fast enouph, the sender could eventually block because of no more
buffer space on receive end.

| Or recevier side network hardware
| will read anyway, just our high-end application has not take the data yet?

Until buffer space is full.

|
| BTW, if one side use sychronous/asychronous way to receive and send, the
| anthoer side does not have to be same, right?

Each side can do either or both. That is a local design choice.

--wjs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top