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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:34:08+00:00 2026-06-12T03:34:08+00:00

The bind() function gets const struct sockaddr *addr as one of parameters. Can I

  • 0

The bind() function gets const struct sockaddr *addr as one of parameters. Can I pass a temp sockaddr structure, that will be deleted immediately after bind() calling?

void bindMe(int socket) {
    struct sockaddr_in addr = {...};
    bind(socket, (struct sockaddr_in*)&addr, sizeof(sockaddr_in));
}
// addr is no more exist after function calling, 
// but I still want to work with the socket.

Also, there is a lot of function in POSIX take pointer to structs. How can I determine if I can free the struct after function calling?

  • 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-12T03:34:10+00:00Added an answer on June 12, 2026 at 3:34 am

    Yes, you can do that. bind is a synchronous system call, so once it returns, the kernel is all done with the parameters.

    If the socket is non-blocking and bind returns EINPROGRESS to indicate that the bind is happening asynchronously, it’s still safe to free the struct. The kernel copies the struct internally while the operation completes asynchronously.

    How can I determine if I can free the struct after function calling?

    Read the documentation. Most POSIX functions are synchronous, and the parameters can safely be deallocated after the function returns, but that’s not always true. If you’re unsure, read the documentation. And obviously if you have multiple threads in your program, you shouldn’t be concurrently modifying the data from another thread while an API call is in progress.

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

Sidebar

Related Questions

$(window).bind(beforeunload,function(){ return cant be seen in ff; }); The problem is that i can't
I'm trying to bind a function with a non-existent class. I will try to
I have this big function that gets a lot of different data and insert
So I have this function that gets data from database and echoes it. The
I am trying to bind an event to a textbox that contains parameters. The
I am using: $('#mypage').live(pageinit, function(){ $('#mypage').bind('pageshow', function() { //json gets data here }...etc My
What does this do: element.bind(resize.container, function() { //..... }); Apparently, it gets called with
I have a function that will change the value of a text box when
I have been defined a bind function , b <- function(f,...) function(x) f(x, ...)
I want to bind a function to an event but I want to change

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.