G
Guest
This is the code example on the MSDN page for the Socket.BeginReceive function:
allDone.Set();
Socket s = (Socket) ar.AsyncState;
Socket s2 = s.EndAccept(ar);
StateObject so2 = new StateObject();
so2.workSocket = s2;
s2.BeginReceive(so2.buffer, 0, StateObject.BUFFER_SIZE,0,
new AsyncCallback(Async_Send_Receive.Read_Callback),
so2);
I have a few questions about this code example:
1) I have seen allDone.Set() on quite a few pages on MSDN examples - what
object is it and what is its purpose?
2) Which of the sockets returned by ar.AsyncState or s.EndAccept() should I
use? What is the difference between them if any?
allDone.Set();
Socket s = (Socket) ar.AsyncState;
Socket s2 = s.EndAccept(ar);
StateObject so2 = new StateObject();
so2.workSocket = s2;
s2.BeginReceive(so2.buffer, 0, StateObject.BUFFER_SIZE,0,
new AsyncCallback(Async_Send_Receive.Read_Callback),
so2);
I have a few questions about this code example:
1) I have seen allDone.Set() on quite a few pages on MSDN examples - what
object is it and what is its purpose?
2) Which of the sockets returned by ar.AsyncState or s.EndAccept() should I
use? What is the difference between them if any?