UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C++
  • » How to get a text file under Windows C++???

#1 2005-01-30 05:38 PM

scape
Member
Registered: 2005-01-30
Posts: 5

Re: How to get a text file under Windows C++???

I am very new to C and C++ programming.  I do have Borland's compiler.  I would like to ask the clearly very knowledgeable persons in this forum what I hope will be a question with a simple answer, perhaps backed up by a few lines of code that will serve as a learning tool.

Is there a way to use the http protocol under C++ to send a message to a server that will cause a text file (rich text file) to be sent to a buffer variable controlled by the requesting C++ software?  (I am functioning more on the level of C than C++, but will work to comprehend C++ code if that is the only way to achieve the goal.) 

I am hoping to avoid using the wininet dll provided with Windows Explorer to eliminate any demands to download that dll (or any similar dll) from a third party.  I can not benefit from code requiring Visual C++ and any non-ANSI header files or class libraries not provided with my compiler, as I am using Borland Turbo C++ 4.5 to try to work through this.

I have no prior experience with the http protocol.  My one attempt at tranferring files was under Visual Basic using a wininet function call (which worked).  Please note that at this moment I would not even know how to establish a socket connection to begin the exchange, or how to close it.  I would need to transfer a fairly large text file to be able to access large reports.  I can live without the need to download graphics embedded in the text for now, but would like to be able to download rich text without losing the formatting of the text.

If any brave soul has the intellectual wherewithal to handle this question, you are in a position to eliminate a question mark that has been bothering me for some time.  Should you choose to respond in the manner requested, you will certainly have my gratitude.

Offline

#2 2005-01-30 06:01 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: How to get a text file under Windows C++???

Offline

#3 2005-01-30 10:05 PM

Nope
Administrator
From: Germany
Registered: 2004-01-24
Posts: 385
Website

Re: How to get a text file under Windows C++???

Offline

#4 2005-01-30 11:03 PM

scape
Member
Registered: 2005-01-30
Posts: 5

Re: How to get a text file under Windows C++???

Thank you!  Your responses have been wonderful and very much appreciated. 

I did take a look at the http/ftp library that was earlier recommended on the web site.  (I avoid the name because I don't want trouble from a corporation asserting some misunderstanding based upon a web post.)  It seems like an impressive package.  I was seriously considering foregoing a very steep learning curve and using it, until I saw the list of code with which one could not link if one were using cURL.  I am not inclined to take legal risks, and do not know where the provider of my compiler and related libraries might have obtained every header file function or dll that was provided (or where I might need to go for a resource in the future).  Secondly, the license sounded a bit unclear to me ("with or without fee" --- does that mean they get to decide after I've used the library?)

I ask that this thread be kept open.  Perhaps someone next week has those few lines of code that it appears at least one other party is inclined to believe may be all that I need to download a richtext file from a remote web site. 

As for what I thought http was: I thought it was a communication protocol used on the internet.  I didn't know if it had limitations regarding the content that it could transmit that was based upon ASCII characters and its ability to recognize those characters.  (Kind of silly in retrospect - interpreting characters during transmission would clearly have ill effects upon server operational speeds.)  I had also heard the "parse" reference before in my prior effort to find a tutorial on the internet that directly addressed how to accomplish my goal under Turbo C++ and Windows. 

Never having "parsed" before, I didn't really want anyone to think that I was looking for a tool that would both read isolated segments of a file dedicated to bitmaps or other graphic file format content and provide text that excluded that content.  I simply (???) want to download a rich text file into a buffer variable under C++ that I specify (not a Windows buffer).  I will eventually require the ability to send a command to log into a password protected web site and provide a user name if I am to actually use this command.  If I can get that far, I may try to find some way to interact with a database later (which I may have to write in C++, as I am very cash poor right now), but I believe that would best be handled by the web site or other tools designed specifically for that purpose.

Offline

#5 2005-01-31 12:18 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: How to get a text file under Windows C++???

Offline

#6 2005-01-31 03:06 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: How to get a text file under Windows C++???

Indeed, I'm not sure what you're complaining about with regard to
curl's license, either...  You really won't find much of anything with
LESS restrictions...  The "with or without fee" quote is referring to
YOUR right to charge or not charge a fee for YOUR software, which
USES libcurl...  They're NOT going to charge YOU a fee, if that's
what you're thinking...  It's free, open-source software...

(Oh, and Nope, *I* linked to libcurl, when I mentioned it, as well! ;-)
Well, now all three of us have linked to it, after i3839's link to the
copyright page... ;-))

Offline

#7 2005-01-31 04:07 PM

scape
Member
Registered: 2005-01-30
Posts: 5

Re: How to get a text file under Windows C++???

My plan is to develop for PALM OS as well as Windows.  cURL is not indicated to work with PALM OS.  As a result, the restrictions I face are somewhat unique, thus driving my pursuit of the methods necessary to embed internet communications and file download capabilities in a C++ program in a manner that provides sufficient foundation to enable generalization sufficient to accomodate the OS of interest.  I have set as my goal the requirement that minimal changes be necessary when compiling for Windows, Windows CE, and PALM OS.

Your input is useful, but I can not be as flexible as a hobbyist in this pursuit.

Thank you.

Offline

#8 2005-01-31 05:16 PM

Nope
Administrator
From: Germany
Registered: 2004-01-24
Posts: 385
Website

Re: How to get a text file under Windows C++???

Offline

#9 2005-01-31 06:11 PM

scape
Member
Registered: 2005-01-30
Posts: 5

Re: How to get a text file under Windows C++???

Thank you for your kind offer of assistance with the http coding.  My saner side may return after I realize the true scope of my goals, inducing me to limit my application to Windows.  I'm certain I would not be the first.  (Borland Builder 6.0's Professional version has many built in controls for FTP and a secure socket control, but it doesn't compile for Palm OS.)

As for Linux, the opportunity to free oneself from a one track world built around a certain operating system clearly has an appeal, but my saner side keeps commenting that the world seems to perceive Linux as a wonderful operating system for servers, but not something for individual users interested in mainstream software.

My background is in engineering, and if Linux should prove to be suitable for some future power monitoring program or substation control application, I will certainly keep this forum in mind.  I admit that I have had certain inclinations to develop hardware and software combinations for such applications in the past.

Offline

#10 2005-01-31 10:32 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: How to get a text file under Windows C++???

Offline

  • Index
  • » C++
  • » How to get a text file under Windows C++???

Board footer

Powered by FluxBB