Thread: Why create a wrapper fo getaddrinfo()

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329

    Why create a wrapper fo getaddrinfo()

    Why do something like

    Code:
    struct addrinto *
    host_serv(const char *host, const char *serv, int family, int socktype)
    {
         int n;
         struct addrinfo hints, *res;
         bzero(&hints, sizeof(struct addrinfo));
         hints.ai_flags = AI_CANONNAME;
         hints.ai_famility = family;
         hints.ai_socktype = socktype;
    
         if( n =  getaddrinfo(host, serv, &hints, &res))  !=0)
              return (NULL);
         
        return (res);
    }
    And then call the function in main() like
    Code:
    struct addrinfo *ai;
    
    ai = Host_serv(host, NULL, 0, 0);
    Why not just call getaddrinfo() directly in main() like
    Code:
    struct addrinfo hints, *res;
    bzero(&hints, sizeof(struct addrinfo));
    hints.ai_flags = AI_CANONNAME;
    hints.ai_famility = family;
    hints.ai_socktype = socktype;
    
    if( n =  getaddrinfo(host, serv, &hints, &res) !=0)
         return (NULL);
    Last edited by Overworked_PhD; 11-09-2007 at 08:50 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can't create child windows
    By OnionKnight in forum Windows Programming
    Replies: 4
    Last Post: 04-10-2011, 04:13 PM
  2. Create new combo boxes based on items selected in preview combo box
    By RealityFusion in forum Windows Programming
    Replies: 2
    Last Post: 01-10-2007, 09:50 AM
  3. How to create a DLL wrapper.
    By MindWorX in forum C Programming
    Replies: 12
    Last Post: 11-09-2006, 02:52 PM
  4. Need help to compile a GTK+ code with C++ sql wrapper
    By kingsz1 in forum C++ Programming
    Replies: 2
    Last Post: 10-12-2006, 06:17 PM
  5. Create a file from c++ program
    By Dan17 in forum C++ Programming
    Replies: 2
    Last Post: 05-08-2006, 04:25 PM