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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:30:58+00:00 2026-05-25T10:30:58+00:00

I am developing c# application, in which i am downloading package(zip file) from server

  • 0

I am developing c# application, in which i am downloading package(zip file) from server machine.It was downloading properly, but recently our package data has got some changes which is flex application.And by using c# we are downloading it into c drive or d drive.

Now with the new package i am facing some problem as
Unable to read data from the transport connection: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.

My code is below

byte[] packageData = null;
packageData = touchServerClient.DownloadFile("/packages/" + this.PackageName);
public byte[] DownloadFile(string url)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(remoteSite.Url + url);
            try
            {
                request.Method = "GET";
                request.KeepAlive = false;                

                request.CookieContainer = new CookieContainer();
                if (this.Cookies != null && this.Cookies.Count > 0)
                    request.CookieContainer.Add(this.Cookies);

                HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse();                

                // Console.WriteLine(response.StatusDescription);

                Stream responseStream = webResponse.GetResponseStream();

                int contentLength = Convert.ToInt32(webResponse.ContentLength);
                byte[] fileData = StreamToByteArray(responseStream, contentLength);                
                return fileData;
            }



public static byte[] StreamToByteArray(Stream stream, int initialLength)
        {
            // If we've been passed an unhelpful initial length, just
            // use 32K.
            if (initialLength < 1)
            {
                initialLength = 32768;
            }

            byte[] buffer = new byte[initialLength];
            int read = 0;

            int chunk;
            while ((chunk = stream.Read(buffer, read, buffer.Length - read)) > 0)
            {
                read += chunk;

                // If we've reached the end of our buffer, check to see if there's
                // any more information
                if (read == buffer.Length)
                {
                    int nextByte = stream.ReadByte();

                    // End of stream? If so, we're done
                    if (nextByte == -1)
                    {
                        return buffer;
                    }

                    // Nope. Resize the buffer, put in the byte we've just
                    // read, and continue
                    byte[] newBuffer = new byte[buffer.Length * 2];
                    Array.Copy(buffer, newBuffer, buffer.Length);
                    newBuffer[read] = (byte)nextByte;
                    buffer = newBuffer;
                    read++;
                }
            }
            // Buffer is now too big. Shrink it.
            byte[] ret = new byte[read];
            Array.Copy(buffer, ret, read);
            return ret;
        }

In the above function(StreamToByteArray) , i am getting error as
Unable to read data from the transport connection: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.

Please help me on this, coz i am not supposed to change the code also.

Thanks in advance
Sangita

  • 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-25T10:30:59+00:00Added an answer on May 25, 2026 at 10:30 am

    A few things to try:

    • Wrap your stream handling in a using statement.

    This will clean up that resource.

    using (Stream responseStream = webResponse.GetResponseStream())
    {
        int contentLength = Convert.ToInt32(webResponse.ContentLength);
        byte[] fileData = StreamToByteArray(responseStream, contentLength);
        return fileData;        
    }
    
    • Make sure there are no other heavy memory processes running on the same box. Particularly if they are making Socket-bound calls.

    • Try upping the value of the MaxUserPort registry value. Here is the article if you didn’t see the link provided in the comments.

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

Sidebar

Related Questions

I am developing an application which queries data from an XML file and creates
i am developing application which send and receive data between two computers but there
I am developing an application which requires the user to drag a file from
I am developing a small application which lists the contents from files of a
i am developing an application which have eight advertisement boxes, the advertisement data with
I am developing an application which download files from internet; the files are mainly
I am developing an application which uses file upload. My client uses Symantec End
I am developing an application which generates barcodes, I want to print them but
I am developing an application in which, I can initialize a call from the
I am developing an Android application which will open Word & excel file. Does

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.