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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:58:15+00:00 2026-05-26T22:58:15+00:00

I am a bit puzzled over how to send a file from an http

  • 0

I am a bit puzzled over how to send a file from an http server to a client(web-browser).

First I send the header and my next task is to send the file content. However I want to send it in segments of say 512 bytes instead of the whole file at once as I ran into some problems.

I am a bit lost on how to achieve that. Here is what I want

read file1;
while (seg=get_next_segment(file1)){
  do
    send(seg)
  until (seg_is_sent)
}

However I can’t seem to find the appropriate functions to achieve that. fread and fseek crossed through my mind but the first one reads the whole file at once and with fseek I don’t see a way to just grab a portion from a file(instead of reading from the file pointer until the end of the file).

  • 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-26T22:58:16+00:00Added an answer on May 26, 2026 at 10:58 pm

    freaddoes not read a whole file to the end. It reads exactly how much you tell it to read.

    size_t
     fread(void *restrict ptr, size_t size, size_t nitems,
         FILE *restrict stream);
    
     size_t
     fwrite(const void *restrict ptr, size_t size, size_t nitems,
         FILE *restrict stream);
    

    Both functions take a size and nitems. You could set the size to 512, and the number of items to 1 (or vice versa) and read just that portion of the file.

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

Sidebar

Related Questions

I'm a bit puzzled: From Cocoa Programming For Mac OS X (page 63, 3rd
I'm a bit puzzled how I'm supposed to use the HTML5 <header> , <section>
I am a little bit puzzled as to how I can optimize my program
I am a bit puzzled with my Regex results (and still trying to get
I am a bit puzzled by this strange behavior on CentOs 5.4 when starting
I'm a bit puzzled about the conditional operator. Consider the following two lines: Float
I'm doing simple divisions in c#, and I am a bit puzzled by its
I'm going through a Fortran code, and one bit has me a little puzzled.
I am a bit puzzled with the Django object models. I have models like
I'm a bit puzzled and I believe I might missing some configuration, or perhaps

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.