CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2010
    Posts
    2

    confused on first parameter of getaddrinfo()

    I have a error on this line:
    getaddrinfo(argv[1], DEFAULT_PORT, &hints, &servinfo)

    DEFAULT_PORT is a macro I made to the port number.
    the next 2 paramters are from:

    struct addrinfo hints, *servinfo;
    ZeroMemory(&hints, sizeof(hints));
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = IPPROTO_TCP;

    There error is with: argv[1]
    It is a undeclared identifier and I can't debug with this error.

    I followed a tutorial to write all my code and it told me to write argv[1]...
    but I thought I was suppposed to write the IP there, Should I write the IP there instead?
    I dont really know what argv[1] means.

    This if for a Client App.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: confused on first parameter of getaddrinfo()

    According to MSDN
    pNodeName [in, optional]
    A pointer to a NULL-terminated ANSI string that contains a ho
    st (node) name or a numeric host address string. For the Internet protocol, the numeric host address string is a dotted-decimal IPv4 address or an IPv6 hex address.
    So if it was set into your argv[1] then it should work, otherwise you'd be probably much easier pass the ip-address directly!?
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured