Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3759568
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:20:12+00:00 2026-05-19T10:20:12+00:00

I have a c# network application where alot of anonymous users connect to (game

  • 0

I have a c# network application where alot of anonymous users connect to (game service).

Now I check the logs and occasionally I see this exception:

[10:30:18.21352] System.Int32 Read(Byte[], Int32, Int32): The stream does not support reading.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at BusinessLayer.Listener.ListenerWorker.ProcessClient(Object obj) in File.cs:line 141

This error comes from a NetworkStream object, now I am trying to reproduce the problem, but how? How can I get this exception?

I tried disconnecting myself, but that just gives a timeout, tried other things, but cannot get it to work.

Maybe somebody has an idea?

Contents of the file is:

private static void ProcessClient(
    Object obj)
{
    ISession session = (ISession)obj;
    NetworkStream networkStream = null;

    try
    {
        DebugUtility.SetThreadName("Worker: {0}", session.Name);
        networkStream = session.TcpClient.GetStream();
        networkStream.ReadTimeout = Config.ReadTimeout;

        // Loop received packets (blocks untill next packet)
        Int32 packetSize;
        Byte[] buffer = new Byte[session.PacketSize];
        while ((packetSize = networkStream.Read(buffer, 0, buffer.Length)) != 0)
        {
            // Get String from packet  bytes
            String packet = Encoding.UTF8.GetString(buffer, 0, packetSize);

            // Check if packet has data
            if (String.IsNullOrEmpty(packet))
                continue;

            // Log biggest received package
            DebugUtility.CheckMaxPacketSize(session.Name, packet.Length);

            // Handle packet (in new thread)
            Logger.DebugLog("Received: {0}", packet);
            ThreadPool.QueueUserWorkItem(session.HandlePacket, packet);
        }
    }
    catch (Exception ex)
    {
        Logger.LogException(ex);
    }
    finally
    {
        if (networkStream != null)
            networkStream.Close();

        if (session != null)
            session.Disconnect();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T10:20:12+00:00Added an answer on May 19, 2026 at 10:20 am

    What arguments are you passing in the

    System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
    

    method. Are you using any of NetworkStream.Length or NetworkStream.Position properties.

    i.e is it somthing like (not exactly)

    System.Net.Sockets.NetworkStream.Read(buffer, stream.Position, stream.Length)
    

    then as explained in MSDN documentation use of NetworkStream.Length and NetworkStream.Position properties will always throw a NotSupportedException as its not currently Supported.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which runs a tool that requires network connection. Now my
I have successfully implemented a network application in visual CLR project using boost.asio. but
I'm debugging a network application. I have to simulate some of the data exchanged
I'm designing an application which will have a network interface for feeding out large
I have an application processing network communication with blocking calls. Each thread manages a
I have a byte array, received from java application via network. I need to
We have an application (a custom network management tool for building automation) that supports
I have a socket application which I can use in local network, at home.
I have a Winforms application (written in C#) that is deployed on a network
Scenario: I have a console application that needs to access a network share with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.