public void Start() { Console.WriteLine("> Starting IWServerIP on port {0}...", m_IWPort); IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0); EndPoint remote = (EndPoint)(sender); m_IWSocket.Bind(m_IWEndPoint); int len = m_IWSocket.ReceiveFrom(m_IWReceiveBuf, ref remote); m_IWReceiveBuf = Encoding.Default.GetBytes(remote.ToString()); MemoryStream stream = new MemoryStream(m_IWReceiveBuf); BinaryReader reader = new BinaryReader(stream); IWHandleIP handleIP = new IWHandleIP(); byte pType = reader.ReadByte(); switch (pType) { case 49: stream.Position = 0; handleIP.HandlePacket(m_IWSocket, remote, len, reader); break; default: Console.WriteLine("Got unk packet: {0}", pType); break; } }