protected void receiveDataFromClient(IAsyncResult datas) { int bytesReceived; try { bytesReceived = ((Socket)datas.AsyncState).EndReceive(datas); } catch { return; } if (bytesReceived > 0) { string data = ASCIIEncoding.ASCII.GetString(this.buffer, 0, bytesReceived); Boolean isPartial = this.checkForPartialData(data); if (!isPartial) { // \x00 Null byte in last index, remove it. string partialdata = this.partialBuffer.ToString(); string[] packet = partialdata.Split(char.Parse("\x00")); this.partialBuffer.Clear(); for (int i = 0; i < packet.Length - 1; i++) { string _loc1_ = packet[i]; var parse = Packets.Parse(_loc1_, this); if (parse == Packets.InvalidPacket) { // Better to remove that penguin Log.Debugger.CallEvent(Airtower.ERROR_EVENT, "Incorrect Packet : " + _loc1_); Airtower.disposeClient(false, this.socket); break; } // handle packets acc to received, if xt or xml if (parse == Packets.XT_DATA) { Log.Debugger.CallEvent(Airtower.XT_EVENT, _loc1_); Packets.HandleXTPacket(this); } else if (parse == Packets.XML_DATA) { Log.Debugger.CallEvent(Airtower.XML_EVENT, _loc1_); if (_loc1_ == "<policy-file-request/>") { this.send(String.Format("<cross-domain-policy><allow-access-from domain='*'" + " to-ports='{0}' /></cross-domain-policy>", Airtower.getCurrentAirtower().PORT)); return; } Packets.HandleXMLPacket(this); } } } this.RecvDataEvent.Set(); } else { Airtower.disposeClient(false, this.socket); } }