Esempio n. 1
0
        public async Task FindStreets(string strCommand, Socket objLocalSocket)
        {
            using (StreetProvider objProvider = new StreetProvider()) {
                List <Street> objStreets = await objProvider.GetStreetByIndexAsync(strCommand);

                byte[] btarrResponse = Encoding.ASCII.GetBytes("NotFound");

                if (objStreets.Count != 0)
                {
                    BinaryFormatter objFormatter = new BinaryFormatter();
                    using (MemoryStream objStream = new MemoryStream()) {
                        objFormatter.Serialize(objStream, objStreets);
                        btarrResponse = objStream.ToArray();
                    }
                }
                objLocalSocket.Send(btarrResponse);
                //objLocalSocket.BeginSend(btarrResponse, 0, btarrResponse.Length, SocketFlags.None, ServerEndAcceptAsync, objLocalSocket);
                ServerEndAcceptAsync(objLocalSocket);
            }
        }
Esempio n. 2
0
      public async Task FindStreets(string strCommand, Socket objLocalSocket) {
         using(StreetProvider objProvider = new StreetProvider()) {
            List<Street> objStreets = await objProvider.GetStreetByIndexAsync(strCommand);

            byte[] btarrResponse = Encoding.ASCII.GetBytes("NotFound");

            if(objStreets.Count != 0) {
               BinaryFormatter objFormatter = new BinaryFormatter();
               using(MemoryStream objStream = new MemoryStream()) {
                  objFormatter.Serialize(objStream, objStreets);
                  btarrResponse = objStream.ToArray();
               }
            }
            objLocalSocket.Send(btarrResponse);
            //objLocalSocket.BeginSend(btarrResponse, 0, btarrResponse.Length, SocketFlags.None, ServerEndAcceptAsync, objLocalSocket);
            ServerEndAcceptAsync(objLocalSocket);
         }
      }