473,322 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Trouble with networking in c++

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.

Oct 3 '06 #1
5 1418

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. )

Oct 3 '06 #2
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.

Oct 3 '06 #3

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

Oct 3 '06 #4
Thanks for that

Oct 3 '06 #5
ge*********@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?
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
Oct 3 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: hyperbob | last post by:
Hello, I'm in the design stage of an application that will consist of two or more processes that will be either on different computers in a network or on the same computer and will have to...
6
by: James Egan | last post by:
I've seen some networking toolkits for C++, but was wondering if there were (or plans for) a standard set of networking classes for C++? Also, can someone tell me where I can find a...
7
by: Brian Keogh | last post by:
Hi, I'm a student learning TCP/IP networking at University. Although I understand all about TCP/IP Networking in Java I am expected to understand the basics of C with regard to these programs as...
46
by: H.A. Sujith | last post by:
Why doesn't the standard library provide (at least basic) networking facilities using TCP/IP ?
4
by: Raj | last post by:
I want to program C with networking. Can anyone tell me the How to start with a small simple program can it possible in turbo/borland c 3+. or i should go for another verson. i am using windows...
0
by: petro | last post by:
I am trying to deploy an asp.net application to my web server. My application uses system.data.oledb to connect to an oracle database. On my development machine I have the oracle client 10g...
2
by: JCB19 | last post by:
I need help networking my HP DV4000 laptop to my home network. I have wireless home network with 3 computers using Linksys Wireless G The laptop has built in wireless capability. I want to...
0
by: haritha | last post by:
HI Friends This blog is very useful to all sections of people. For Pc trouble shooting skills,Linux,Html Webdesigning,Free softwares,Networking skills,Gaming news and For Tips visit the blog:...
1
by: chinaemerem ibeawuchi | last post by:
What is the difference between URL networking and Socket networking? with an example of each type and state why the choosen networking technique is most appropriate for the example.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.