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 874863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:10:27+00:00 2026-05-15T11:10:27+00:00

This one puzzles me. I get an error about seek when I’m not even

  • 0

This one puzzles me. I get an error about seek when I’m not even calling it?

I have code that looks something like this:

// send 42
uint value = 42;
byte[] msg = BitConverter.GetBytes(value);
stream.Write(msg, 0, sizeof(uint));

and I get this exception:

System.NotSupportedException was unhandled
Message="This stream does not support seek operations."
Source="System"
StackTrace:
   at System.Net.Sockets.NetworkStream.Seek(Int64 offset, SeekOrigin origin)
   at System.IO.BufferedStream.FlushRead()
   at System.IO.BufferedStream.Write(Byte[] array, Int32 offset, Int32 count)
...

stream is of type System.IO.BufferedStream. What could possibly be going on?

edit with more info:

sizeof(uint)==msg.length in this case.
The stream is declared as stream = new BufferedStream(new NetworkStream(socket), 1024)

edit:

That was it! While one can read and write on a single NetworkStream, when switching to a BufferedStream it is necessary to have a separate one for reading and writing. One can apparently just call the NetworkStream constructor twice on the same socket to get that.

I’d accept both Justin and Hans’ answers if I could, because one let me exactly understand what was wrong, and the other led me to the solution. Thanks everyone!

  • 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-15T11:10:28+00:00Added an answer on May 15, 2026 at 11:10 am

    The problem lies in the inner workings of BufferedStream (and the fact that you may have used the BufferedStream to Read from prior to attempting to write to it).

    When you try to Write to a BufferedStream, after validating your parameters, things are checked in this order (all code pulled from the Framework via Reflector):


    Are we at the begging of the write buffer?

    if(this._writePos == 0)
    

    Are we allowed to write to the underlying stream?

    if(!this._s.CanWrite) // throw error
    

    Is the Read buffer empty?

    if(this._readPos < this._readLen)
    {
        // FlushRead() will attempt to call Seek()
        this.FlushRead();
    }
    

    If there is unread data in the read buffer, a Flush is attempted before writing. FlushRead() calls Seek(), which is what is causing your error.

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

Sidebar

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.