TcpClient has a method called GetworkStream GetStream();
So in other words, there is only one stream associate with it for input and
output, right?
So while it is receiving, it can not send, and vise visa, right? So will it
be a problem both server and client can initiative a sending action?
TcpClient only supports synchronous operation. What does "Synchronou s" mean?
Means while it is reading or waiting for data to arrive from the stream, it
will block current thread? Does it also mean it will block another thread
in the same process from sending data though this stream? Or just an
exception while other thread sends data.
But of cause it can not block the computer on the another side of stream,
what happen another side client computer call Steam's read method?
Socket does not has such method like GetStream(), but it supports
asynchronous operation. Does this means it has 2 streams for input and
output?
And what does "asynchrono us" mean? If I have a server keep receiving
message from clients, if I use BeginReceive() method, is that means in the
endless loop, it will create a thread each time when it executes
BeginReceive(). Creating so many threads will it hurt performance of the
server?
And is that true, I need an endless loop to receive all messages from one
client, and if each message is long, just to receive a single message
(message has the header to tell the total length), it might need get data
from multiple BeginReceive()? And data get from one BeginReceive() might
has first part belong to previous message and the rest for next message?
On server side, I think to minimize the resource usage, it is better just
keep one thread for each client. This thread will receive data from client,
and when one complete message received, it process this message in the same
thread. Is this reasonable?
But if multiple BeginReceive() get one message, each BeginReceive() creates
a thread, then this is really different from my intention to reduce the
resource usage.
Sever programming is a difficult task for me. I've asked too many questions.
Really appreciate for your help!
Ryan
So in other words, there is only one stream associate with it for input and
output, right?
So while it is receiving, it can not send, and vise visa, right? So will it
be a problem both server and client can initiative a sending action?
TcpClient only supports synchronous operation. What does "Synchronou s" mean?
Means while it is reading or waiting for data to arrive from the stream, it
will block current thread? Does it also mean it will block another thread
in the same process from sending data though this stream? Or just an
exception while other thread sends data.
But of cause it can not block the computer on the another side of stream,
what happen another side client computer call Steam's read method?
Socket does not has such method like GetStream(), but it supports
asynchronous operation. Does this means it has 2 streams for input and
output?
And what does "asynchrono us" mean? If I have a server keep receiving
message from clients, if I use BeginReceive() method, is that means in the
endless loop, it will create a thread each time when it executes
BeginReceive(). Creating so many threads will it hurt performance of the
server?
And is that true, I need an endless loop to receive all messages from one
client, and if each message is long, just to receive a single message
(message has the header to tell the total length), it might need get data
from multiple BeginReceive()? And data get from one BeginReceive() might
has first part belong to previous message and the rest for next message?
On server side, I think to minimize the resource usage, it is better just
keep one thread for each client. This thread will receive data from client,
and when one complete message received, it process this message in the same
thread. Is this reasonable?
But if multiple BeginReceive() get one message, each BeginReceive() creates
a thread, then this is really different from my intention to reduce the
resource usage.
Sever programming is a difficult task for me. I've asked too many questions.
Really appreciate for your help!
Ryan
Comment