Banner

Repeat

End

Forums

HavenForts: Construct JetFists - The Chronicles of Wargasm (Episode 2, NeoForts)
  #91  
Old 11-28-2007
Fumigator
Fort Warrior
 
Join Date: Aug 2007
Location: Holland
Posts: 1,672
Send a message via MSN to HisChild
Default

I am pretty reluctant to include dll's, for the very simple reason that not every system has them and it's already a real pain in the ass to get it running on linux ....
but yes, that is an idea... i MIGHT look into it, but NOT for 193.
Reply With Quote
  #92  
Old 11-28-2007
Disturber's Avatar
Doctor of Medicine
Master Craftsman
 
Join Date: Jan 2006
Location: MD
Posts: 891
Default

Even better: no (extra) DLL. Just use the API:
Windows HTTP Services (WinHTTP) uses winhttp.dll (part of the OS)
Sample code is in effect on MSDN:
Code:
  DWORD dwSize = 0;
  DWORD dwDownloaded = 0;
  LPSTR pszOutBuffer;
  BOOL  bResults = FALSE;
  HINTERNET  hSession = NULL, 
             hConnect = NULL,
             hRequest = NULL;

  // Use WinHttpOpen to obtain a session handle.
  hSession = WinHttpOpen( L"WinHTTP Example/1.0",  
                          WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
                          WINHTTP_NO_PROXY_NAME, 
                          WINHTTP_NO_PROXY_BYPASS, 0 );

  // Specify an HTTP server.
  if( hSession )
    hConnect = WinHttpConnect( hSession, L"www.microsoft.com",
                               INTERNET_DEFAULT_HTTPS_PORT, 0 );

  // Create an HTTP request handle.
  if( hConnect )
    hRequest = WinHttpOpenRequest( hConnect, L"GET", NULL,
                                   NULL, WINHTTP_NO_REFERER, 
                                   WINHTTP_DEFAULT_ACCEPT_TYPES, 
                                   WINHTTP_FLAG_SECURE );

  // Send a request.
  if( hRequest )
    bResults = WinHttpSendRequest( hRequest,
                                   WINHTTP_NO_ADDITIONAL_HEADERS, 0,
                                   WINHTTP_NO_REQUEST_DATA, 0, 
                                   0, 0 );


  // End the request.
  if( bResults )
    bResults = WinHttpReceiveResponse( hRequest, NULL );

  // Keep checking for data until there is nothing left.
  if( bResults )
  {
    do 
    {
      // Check for available data.
      dwSize = 0;
      if( !WinHttpQueryDataAvailable( hRequest, &dwSize ) )
        printf( "Error %u in WinHttpQueryDataAvailable.\n",
                GetLastError( ) );

      // Allocate space for the buffer.
      pszOutBuffer = new char[dwSize+1];
      if( !pszOutBuffer )
      {
        printf( "Out of memory\n" );
        dwSize=0;
      }
      else
      {
        // Read the data.
        ZeroMemory( pszOutBuffer, dwSize+1 );

        if( !WinHttpReadData( hRequest, (LPVOID)pszOutBuffer, 
                              dwSize, &dwDownloaded ) )
          printf( "Error %u in WinHttpReadData.\n", GetLastError( ) );
        else
          printf( "%s", pszOutBuffer );

        // Free the memory allocated to the buffer.
        delete [] pszOutBuffer;
      }
    } while( dwSize > 0 );
  }


  // Report any errors.
  if( !bResults )
    printf( "Error %d has occurred.\n", GetLastError( ) );

  // Close any open handles.
  if( hRequest ) WinHttpCloseHandle( hRequest );
  if( hConnect ) WinHttpCloseHandle( hConnect );
  if( hSession ) WinHttpCloseHandle( hSession );
Doesn't give you a solution for server, but I think the client is the bigger concern anyway.
__________________
disturber
"Live as if you were to die tomorrow. Learn as if you were to live forever."
-- Mohandas Karamchand (Mahatma) Gandhi.

Questions about SourceForts? Try the wiki.
Reply With Quote
  #93  
Old 11-29-2007
Fumigator
Fort Warrior
 
Join Date: Aug 2007
Location: Holland
Posts: 1,672
Send a message via MSN to HisChild
Default

Quote:
Originally Posted by HisChild View Post
I am pretty reluctant to include dll's, for the very simple reason that not every system has them and it's already a real pain in the ass to get it running on linux ....
but yes, that is an idea... i MIGHT look into it, but NOT for 193.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:20 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.0

Tab