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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:06:35+00:00 2026-06-09T22:06:35+00:00

This question is on system calls pread and lseek . I have a file

  • 0

This question is on system calls pread and lseek .
I have a file descriptor of socket type . Data is added to it whenever packet is read from the network layer . I would like to know whats the amount of data present in the file descriptor at regular intervals .

I tried using the systems calls pread and lseek , so that I know only the amount of data rather than reading data itself . But , both the calls fails giving Illegal seek error. Are there any other systems calls on the socket type file descriptor or pread and lseek are not supported on socket fd? .

Best
Yash

  • 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-06-09T22:06:36+00:00Added an answer on June 9, 2026 at 10:06 pm

    Linux manpages say that sockets interface doesn’t support seek operations:

    Seeking, or calling pread(2) or pwrite(2) with a nonzero position is
    not supported on sockets.

    You can try issuing recv with with the following flags set (MSG_PEEK|MSG_DONTWAIT) specifying the buffer of a sufficient size.

    This operation will copy the data from socket’s receive buffer, but won’t pop it out i.e. a subsequent recv/read call will read all the same data + some more data might arrive on socket so the number of bytes returned might be even greater.

    The buffer size is a very sticky point there – it should be greater than the socket receive buffer, otherwise there is a chance your recv call will return the number of bytes there are in the buffer you provided, but the socket actually has some more.

    The size of the socket receive buffer can be obtained by means of getsockopt function with the option name SO_RCVBUF.

    Btw, I think a better option would be to actually read the data and keep it in the buffer somewhere. When you’ve read enough data, do some actions with it. This seems to be a better and more common approach than peeking into the socket receive buffer without extracting data.

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

Sidebar

Related Questions

Where are some lists of system calls on UNIX? This wasn't my original question,
Stupid question, this code: <?php $variable = system(cat /home/maxor/test.txt); echo $variable; ?> with file
Just a general curiosity question. Why is this namespace System.Collections.Generic added by default in
Question: I need to make some system calls in my C# applications. Unfortunately, this
I have question regarding shared memory segmentation in c using POSIX system calls. Is
How do you prevent a file descriptor from being copy-inherited across fork() system calls
In this question the OP implies that he wants to base the blog system
Yesterday, I asked this question regarding best practices for a simple information retrieval system
Edited Question: This should be clear. using System; namespace UpdateDateTimeFields { class Program {
Looking in this StackOverflow question it uses the following to send emails: System.Net.Mail.SmtpClient Is

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.