Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TcpClient connection = new TcpClient(hostname, port);
- NetworkStream stream = connection.GetStream();
- thread = new Thread(ProcessStream);
- thread.Start(stream);
- private void ProcessStream(object stream)
- {
- Stream source = (NetworkStream)stream;
- byte[] line;
- int count;
- const int capacity = 300;
- ReadState readState;
- while ((readState = ReadStreamLine(source, out line, out count, capacity)) != ReadState.EOF && _stopFeed == false)
- {
- if (readState != ReadState.Error && count > 4)
- {
- byte[] line1 = new byte[count];
- Array.Copy(line, line1, count);
- Process(line1); // return ignored in stream mode
- }
- else
- {
- ReadFail(line, count);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement