Like Tree1Likes
  • 1 Post By Salem

WININET HttpOpenRequest Help

This is a discussion on WININET HttpOpenRequest Help within the Windows Programming forums, part of the Platform Specific Boards category; I am trying to check if a port is open using the internet site ismyportopen.com, i seem to get to ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    319

    WININET HttpOpenRequest Help

    I am trying to check if a port is open using the internet site ismyportopen.com, i seem to get to the function HttpOpenRequest working with this get request...

    g_hHttpRequest = HttpOpenRequest(g_hNetSession, "GET //processors/port-check.php?ip=xxx.xx.x.xxx&port=80&t=1406357001803" , "", "HTTP/1.1", "", NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
    if(g_hHttpRequest == NULL)
    printf("HttpOpenRequest() returned NULL %d\n",GetLastError());

    GetlastError returns
    ERROR_INVALID_PARAMETER
    87 (0x57)
    The parameter is incorrect.

    the string was captured with a chrome http logger so i dont know how its giving me an error..

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,823
    HttpOpenRequest function (Windows)
    Notice how everything is a TSTR

    Using Generic-Text Mappings
    You need to use _TEXT("foo") in place of all your "foo" strings.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    Now ive got this

    g_hNetSession = InternetConnect(g_hRoot, _TEXT("ismyportopen.com"), INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);

    g_hHttpRequest = HttpOpenRequest(g_hNetSession, _TEXT("GET //processors/port-check.php?ip=xxx.xx.x.xxx&port=5050&t=140635700180 3"), "", _TEXT("HTTP/1.1"), "", NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);

    But still have the same issue,btw thanks for replying...
    Last edited by Anddos; 07-26-2014 at 10:18 AM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,823
    Sure, and what about these as well?

    _TEXT("")
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    Those are set to NULL instead now

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    Still cant get it working

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,823
    g_hHttpRequest = HttpOpenRequest(g_hNetSession, _TEXT("GET //processors/port-check.php?ip=xxx.xx.x.xxx&port=5050&t=140635700180 3"), "", _TEXT("HTTP/1.1"), "", NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
    > Those are set to NULL instead now

    Are you even reading the manual page?
    Parameters

    hConnect [in]
    A handle to an HTTP session returned by InternetConnect.

    lpszVerb [in]
    A pointer to a null-terminated string that contains the HTTP verb to use in the request. If this parameter is NULL, the function uses GET as the HTTP verb.

    lpszObjectName [in]
    A pointer to a null-terminated string that contains the name of the target object of the specified HTTP verb. This is generally a file name, an executable module, or a search specifier.

    lpszVersion [in]
    A pointer to a null-terminated string that contains the HTTP version to use in the request. Settings in Internet Explorer will override the value specified in this parameter.
    If this parameter is NULL, the function uses an HTTP version of 1.1 or 1.0, depending on the value of the Internet Explorer settings.
    Where do you see in this that the 3rd parameter can be NULL ?

    You might also wonder why you think the empty string is a good idea as well.

    > Still cant get it working
    That's a shame.
    But you need to post your latest code and error messages if you want a better response.
    Ideally, code that will compile and run. A few lines barely cuts it, and 1-line posts of "it doesn't work" are a complete waste of space.
    Sebastiani likes this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. wininet
    By jopp3 in forum C Programming
    Replies: 0
    Last Post: 04-29-2007, 10:27 AM
  2. My tut on WinINet...
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 04-24-2007, 12:33 PM
  3. HttpOpenRequest lplpszAcceptTypes
    By abachler in forum Networking/Device Communication
    Replies: 3
    Last Post: 04-17-2007, 02:16 PM
  4. wininet/gcc - how to?
    By cdave in forum Windows Programming
    Replies: 3
    Last Post: 11-15-2005, 06:10 PM
  5. Error code 1813 after calling HttpOpenRequest
    By jmd15 in forum Networking/Device Communication
    Replies: 1
    Last Post: 09-10-2005, 11:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21