public static void AcceptCallback(IAsyncResult ar) { // Signal the main thread to continue. allDone.Set(); // Get the socket that handles the client request. Socket listener = (Socket)ar.AsyncState; Socket handler = listener.EndAccept(ar); // Create the state object. StateObject state = new StateObject(); state.workSocket = handler; state.clientHandler = new ClientHandler(handler, legend); var readyPacket = new Packets.ReadyPacket(0); AsynchronousSocketListener.Send(state.workSocket, readyPacket); handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state); }
public void SendPacket(Packet packet) { AsynchronousSocketListener.Send(handler, packet); }