M
Mochuelo
Hi,
I'm working with an asynchronous TCP server. I have a few questions
that may seem silly, but I can't get to understand all this.
Let's say that BeginAccept will cause the AcceptCallback method being
executed, and that BeginReceive will cause the ReadCallback method
being execute. I have played a little bit with them, it looks like the
AcceptCallback method gets executed right when a (local or remote)
client requests to connect to this server. I believe that when the
server executes the EndAccept method, it is accepting the connection.
My first silly question is: Why would the server want to reject a
specific connection request, if the Listen method has already
specified in advance the maximum number of simultaneous connections I
want to allow? Could anyone give me an example of a criterium under
which I could want to reject a connection request, assuming the max
number of connections has NOT been reached yet?
Can I know the IP of the client, before accepting the connection
request?
Another question is: The help for BeginAccept says, among other
things:
"Your callback method should implement the EndAccept method. When
your application calls BeginAccept, the system uses a separate thread
to execute the specified callback method and blocks on EndAccept until
a pending connection is retrieved."
I don't understand why it says "blocks". ReadCallback is executed
right at the beginning of every chunk received, or at the end? If it
is executed at the beginning, I could understand the "block". It would
block until the end of the chunk is reached, when all the chunk data
is finally present in the receive buffer. If ReadCallback is executed
at the end of every chunk received, I don't understand the word
"block". Could someone help me understand this?
Thank you very much.
I'm working with an asynchronous TCP server. I have a few questions
that may seem silly, but I can't get to understand all this.
Let's say that BeginAccept will cause the AcceptCallback method being
executed, and that BeginReceive will cause the ReadCallback method
being execute. I have played a little bit with them, it looks like the
AcceptCallback method gets executed right when a (local or remote)
client requests to connect to this server. I believe that when the
server executes the EndAccept method, it is accepting the connection.
My first silly question is: Why would the server want to reject a
specific connection request, if the Listen method has already
specified in advance the maximum number of simultaneous connections I
want to allow? Could anyone give me an example of a criterium under
which I could want to reject a connection request, assuming the max
number of connections has NOT been reached yet?
Can I know the IP of the client, before accepting the connection
request?
Another question is: The help for BeginAccept says, among other
things:
"Your callback method should implement the EndAccept method. When
your application calls BeginAccept, the system uses a separate thread
to execute the specified callback method and blocks on EndAccept until
a pending connection is retrieved."
I don't understand why it says "blocks". ReadCallback is executed
right at the beginning of every chunk received, or at the end? If it
is executed at the beginning, I could understand the "block". It would
block until the end of the chunk is reached, when all the chunk data
is finally present in the receive buffer. If ReadCallback is executed
at the end of every chunk received, I don't understand the word
"block". Could someone help me understand this?
Thank you very much.