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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:41:35+00:00 2026-05-28T17:41:35+00:00

I am sending file from client to server using TCP. To mark the end

  • 0

I am sending file from client to server using TCP. To mark the end of the file I like to send file size before the actual data. So I use stat system call to find the size of the file. This is of type off_t. I like to know how many bytes it occupies so that I can read it properly on the server side. It is defined in the <sys/types.h>. But I do not understand the definition. It just defines __off_t or _off64_t to be off_t. Where to look for __off_t? Also is it convention that __ is prefixed for most of the things in header files and scares me when I read header files to understand better. How to read a header file better?

#ifndef __off_t_defined
# ifndef __USE_FILE_OFFSET64
typedef __off_t off_t;
# else
typedef __off64_t off_t;
# endif
# define __off_t_defined
#endif 
  • 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-28T17:41:36+00:00Added an answer on May 28, 2026 at 5:41 pm

    Since this answer still gets voted up, I want to point out that you should almost never need to look in the header files. If you want to write reliable code, you’re much better served by looking in the standard. So, the answer to "where can I find the complete definition of off_t" is "in a standard, rather than a header file". Following the standard means that your code will work today and tomorrow, on any machine.

    In this case, off_t isn’t defined by the C standard. It’s part of the POSIX standard, which you can browse here.

    Unfortunately, off_t isn’t very rigorously defined. All I could find to define it is on the page on sys/types.h:

    blkcnt_t and off_t shall be signed integer types.

    This means that you can’t be sure how big it is. If you’re using GNU C, you can use the instructions in the answer below to ensure that it’s 64 bits. Or better, you can convert to a standards defined size before putting it on the wire. This is how projects like Google’s Protocol Buffers work (although that is a C++ project).


    For completeness here’s the answer to "which header file defines off_t?":

    On my machine (and most machines using glibc) you’ll find the definition in bits/types.h (as a comment says at the top, never directly include this file), but it’s obscured a bit in a bunch of macros. An alternative to trying to unravel them is to look at the preprocessor output:

    #include <stdio.h>
    #include <sys/types.h>
    
    int main(void) {
      off_t blah;
    
      return 0;
    }
    

    And then:

    $ gcc -E sizes.c  | grep __off_t
    typedef long int __off_t;
    ....
    

    However, if you want to know the size of something, you can always use the sizeof() operator.

    Edit: Just saw the part of your question about the __. This answer has a good discussion. The key point is that names starting with __ are reserved for the implementation (so you shouldn’t start your own definitions with __).

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

Sidebar

Related Questions

I write a client-server application which will be sending an .xml file from the
I'm trying to send a file from a client to a server, so I
I have a client and server, client sending file to server. When i transfer
I am sending a POST request using HTTPWebRequest from the client to the Cassini
I am using Named Pipes to transfer data from a client (C++) to a
Hi I want to send a fixed amount of data (say 5MB) from server
I have an application using sockets.. a client and server program like mySql.. I
I am using this for sending file to user header('Content-type: application/zip'); header('Content-Length: ' .
I'm reading in a file and sending the data (once encrypted) to a dictionary,
I need to empty an LDF file before sending to a colleague. How do

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.