Example #1
0
        private void ReadLengthPrefix(Client client, bool continuous)
        {
            if (client.Disposed)
            {
                return;
            }

            PrefixReader prefixReader = new PrefixReader(this.server.Buffers);

            try
            {
                client.Socket.BeginReceive(
                    prefixReader.Buffer,
                    0,
                    PrefixReader.PrefixBytes,
                    SocketFlags.None, this.LengthPrefixReceivedCallback,
                    Tuple.Create(client, prefixReader, continuous));
            }
            catch
            {
                client.ErrorsAccumulated++;
                prefixReader.Dispose();
                client.Dispose();
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            var watcher = Stopwatch.StartNew();

            PrefixReader.Process(new FileStream(TestIn, FileMode.Open), new FileStream(TestOut, FileMode.Create));
            watcher.Stop();
            Console.WriteLine("Поиск слов в файле {0} занял {1}", Path.GetFullPath(TestIn), watcher.Elapsed);
        }
        private void ReadLengthPrefix(bool continuous)
        {
            PrefixReader prefixReader = new PrefixReader(this.client.Buffers);

            try
            {
                this.client.Socket.BeginReceive(
                    prefixReader.Buffer,
                    0,
                    PrefixReader.PrefixBytes,
                    SocketFlags.None, this.LengthPrefixReceivedCallback,
                    Tuple.Create(prefixReader, continuous));
            }
            catch
            {
                prefixReader.Dispose();
                this.ReadMessagesContinuously();
            }
        }