/// <summary> /// Assign a new socket & client to this context. /// </summary> /// <param name="socket">Socket that connected</param> /// <param name="client">Your own class dealing with this particular client.</param> public void Assign(Socket socket, IServerService client) { if (socket == null) throw new ArgumentNullException("socket"); if (client == null) throw new ArgumentNullException("client"); _socket = socket; _client = client; _client.Assign(this); _writer.Assign(socket); var willRaiseEvent = _socket.ReceiveAsync(_readArgs); if (!willRaiseEvent) OnReadCompleted(_socket, _readArgs); }