
Untitled
By: a guest on
Aug 5th, 2012 | syntax:
None | size: 0.80 KB | hits: 12 | expires: Never
Periodically send data from server to clients
public void AcceptCallback(IAsyncResult ar)
{
allDone.Set(); // Signal the main thread to continue.
// Get the socket that handles the client request.
Socket listener = (Socket)ar.AsyncState;
Socket handler = listener.EndAccept(ar);
IPEndPoint remotePoint = (IPEndPoint)handler.RemoteEndPoint;
IPAddress remoteAddress = remotePoint.Address;
Console.WriteLine("Connected to {0}!", remoteAddress.ToString());
// Create the state object.
StateObject state = new StateObject();
state.workSocket = handler;
//Start periodically sending here??
handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,
new AsyncCallback(ReadCallback), state);
}