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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:56:46+00:00 2026-05-26T13:56:46+00:00

any help would be appreciated. Im developing a udp connection and i have a

  • 0

any help would be appreciated. Im developing a udp connection and i have a function that initialize the parameters of an address.
here is the code

void Socket::InitAddrInfoStruct (struct addrinfo *hints, bool socktype){

/* Setting addrinfo struct */
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; // set to AF_INET to force IPv4
if(socktype == true)
    hints.ai_socktype = SOCK_DGRAM; // set to SOCK_DGRAM to force UDP protocol type
else
    hints.ai_socktype = SOCK_STREAM; // set to SOCK_STREAM to force TCP protocol type
hints.ai_flags = AI_PASSIVE; // use my IP

}

when i try to compile i got the following error:
request for member ‘ai_family’ in ‘hints’, which is of non-class type ‘addrinfo*’

can anyone help me on how i should add data to the struct hints?

  • 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-26T13:56:47+00:00Added an answer on May 26, 2026 at 1:56 pm

    The error is saying that hints is not of class type, and indeed its a pointer. You should access its members with -> instead:

    hints->ai_family = AF_UNSPEC;
    

    or alternatively:

    (*hints).ai_family = AF_UNSPEC;
    

    Also, as @Anders K. pointed out, your memset is probably wrong since you are invoking it with the size of a pointer. It should be:

     memset(hints, 0, sizeof(*hints) );
    

    or alternatively:

     memset(hints, 0, sizeof(struct addrinfo) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any help here would be greatly appreciated. I have this table hospital Nurse |
Any help would be appreciated, I'm trying to convert the code below to C#,
I am new to jQuery. Any help would be appreciated I have two radio
I am relatively new to db design, so any help here would be appreciated.
I am struggling to carry out the following. Any help would be greatly appreciated.
Finding windows FastCGI help is proving very difficult. Any help would be greatly apprciated.
I would appreciate any help on this issue. Lets say I want to load
Would very much appreciate any help or hint on were to go next. I'm
I would really appreciate any suggestions, no matter how simple or complex, to help
Is there an alternative to history.go(-1) for FireFox and Safari. Any Help would be

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.