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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:23:03+00:00 2026-05-25T15:23:03+00:00

I am coding an application for linux in C, it will receive thousands of

  • 0

I am coding an application for linux in C, it will receive thousands of UDP messages which may be of variable size. Somehow, I have to get the message size, before reading it into the buffer with recvfrom() syscall. I can not allocate memory for the maximum possible message, because since I use MTU of 9,000 and get thousands of messages a lot of memory will be wasted.
I checked in google, it is possible to find out what is the size of the message with SO_NREAD option for getsockopt syscall, however this works only on BSD. I know the message is located somewhere in Linux kernel because my sockets are working in non-blocking mode and I am being notified by kernel events that the data is available, so, somewhere it has to store the message length, but how can I get it ?

Thanks in advance

  • 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-25T15:23:03+00:00Added an answer on May 25, 2026 at 3:23 pm

    You probably want to use ioctl with FIONREAD. It’s available for both Linux and BSD.

    FIONREAD int Get the number of bytes that are immediately available for reading.

    if(ioctl(s, FIONREAD, &bytes) != -1)
        printf("%d bytes available", bytes);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm coding an MFC application in which i have a dialog box with multiple
I have started coding an FTP client application (for fun). I’m trying to represent
I have an application using JACK MIDI under Linux. It works perfectly on 32
This is my application setup. I have written an application (in Qt ) which
I have been coding application from past 1 year, However first time I came
i am coding an OOP application in PHP. I want to have a Superclass
I'm coding an application that needs to select an area of the screen. I
I’m coding an application with server resources in mind, so I don’t want to
assume that i start coding an application from scratch, is the best way to
In coding a traditional MVC application, what is the best practice for coding server-side

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.