Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Trouble with networking in c++

Reply
Thread Tools

Trouble with networking in c++

 
 
genericdave@gmail.com
Guest
Posts: n/a
 
      10-03-2006
I'm writing a cgi application in c++ that will run server side in
apache and I'm having a bit of trouble. Basically I'm trying to get
the program to download the html from another site and store that html
in a variable so I can parse it.

I've tried using libcurl, but it exits strangely. And I've tried
running other programs like wget using the system() command, but as far
as I know there is no way to capture the html wget downloads before it
outputs it to a file. I could read it from the file wget creates, but
that would be slow.

I'd appreciate any help I can get. Thanks.

 
Reply With Quote
 
 
 
 
BigBrian
Guest
Posts: n/a
 
      10-03-2006

genericd...@gmail.com wrote:
> I'm writing a cgi application in c++ that will run server side in
> apache and I'm having a bit of trouble. Basically I'm trying to get
> the program to download the html from another site and store that html
> in a variable so I can parse it.
>
> I've tried using libcurl, but it exits strangely. And I've tried
> running other programs like wget using the system() command, but as far
> as I know there is no way to capture the html wget downloads before it
> outputs it to a file. I could read it from the file wget creates, but
> that would be slow.
>
> I'd appreciate any help I can get. Thanks.


What's your question about the C++ language? ( That's what we talk
about in this newsgroup. )

 
Reply With Quote
 
 
 
 
genericdave@gmail.com
Guest
Posts: n/a
 
      10-03-2006
Would it be possible to capture the output from a program that I call
on the command line? For example when I call:

system("curl.exe somewebsite.com");

it displays the html on the the command line, but I can't figure out
how to store this output in a variable. Is this even possible?

Oh and sorry if this is the wrong place for this.

 
Reply With Quote
 
BigBrian
Guest
Posts: n/a
 
      10-03-2006

genericd...@gmail.com wrote:
> Would it be possible to capture the output from a program that I call
> on the command line? For example when I call:
>
> system("curl.exe somewebsite.com");
>
> it displays the html on the the command line, but I can't figure out
> how to store this output in a variable. Is this even possible?
>
> Oh and sorry if this is the wrong place for this.


This is off topic here, but I'd suggest that you learn about libcurl
and understand the error that it was giving. Anything that you do with
system() will be system dependant and not portable. Personally, I have
used libcurl to do what you're trying to do, so I know it can be done.

-Brian

 
Reply With Quote
 
genericdave@gmail.com
Guest
Posts: n/a
 
      10-03-2006
Thanks for that

 
Reply With Quote
 
Marcus Kwok
Guest
Posts: n/a
 
      10-03-2006
wrote:
> Would it be possible to capture the output from a program that I call
> on the command line? For example when I call:
>
> system("curl.exe somewebsite.com");
>
> it displays the html on the the command line, but I can't figure out
> how to store this output in a variable. Is this even possible?


It is possible but not directly. One way is to redirect the output from
your system call into a file, then open that file normally... something
like (untested):

system("curl.exe somewebsite.com > temp_file");
std::ifstream in_file("temp_file");

This is assuming that your environment supports redirecting output like
that (many do).

[OT]
If you want to do it directly without creating a temporary file, I've
heard there is a function called popen() that may do what you want, but
this is a platform-specific function, so you'll have to ask about that
somewhere where it would be topical.
[/OT]

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet networking , group networking,business leads,new business opportunities,like having many sales peoples elie Computer Support 0 08-18-2007 10:12 AM
networking two pc together with wireless networking ? Andy Wireless Networking 4 02-26-2007 06:02 PM
PROBLEMS WITH NETWORKING - NEW TO NETWORKING =?Utf-8?B?QUJTUE9QVVA=?= Wireless Networking 2 03-23-2005 08:31 AM
[Reminder] Online chat with Networking & Devices VP about Networking in Longhorn Eddy Malik [MSFT] Wireless Networking 0 03-22-2005 03:27 AM
networking 2 pc with a networking hub and 1 internet connection barry crowley Computer Support 20 02-27-2004 05:09 AM



Advertisments