Пример #1
0
        public static int HandlePacket(int s, byte *buf, int buflen, int flags, IntPtr from, IntPtr fromlenptr)
        {
            if (buflen == -1)
            {
                return(-1);
            }
            var type = ClassifyPacket(buf, buflen);


            switch (type)
            {
            case PacketType.Good:
            default:
                var len = OHook_recvfrom(s, buf, buflen, flags, from, fromlenptr);
                return(len);

            case PacketType.Invalid:
                return(-1);

            case PacketType.Info:
                var addr = (SockAddrIn *)from;
                var IP   = new IPAddress(addr->Addr);
                //Console.WriteLine("A2S_INFO REQUEST: " + IP);
                NativeSocket.SendTo(udpSock, staticInfoPacket, staticInfoPacket.Length, 0, from, *((int *)fromlenptr));
                return(-1);

            case PacketType.Player:
                NativeSocket.SendTo(udpSock, staticPlayerPacket, staticPlayerPacket.Length, 0, from, *((int *)fromlenptr));
                return(-1);
            }
        }
Пример #2
0
 public static int HandleNetError(int len)
 {
     if (len == -1)
     {
         NativeSocket.WSASetLastError(NativeSocket.WSAEWOULDBLOCK);
     }
     return(len);
 }