Solved

VC++ I need code to open a socket, send a query and capture the output

Posted on 2001-06-08
3
306 Views
Last Modified: 2008-03-10
I need to query an on-line database 12,000 times.
Each query is of the following form (with different criteria each time):

http://genome-www4.stanford.edu/cgi-bin/SMD/source/sourceResult?option=CloneID&choice=cDNA&criteria=111e2t7

According to "Windows Sockets: Sequence of Operation",
it looks like I will have to

// construct a socket
CSocket sockClient;
// create the SOCKET
sockClient.Create( );
// seek a connection
sockClient.Connect(strAddr, nPort);
// construct file object
CSocketFile file(&sockClient);
// construct input and output archives
CArchive arIn(&file,
         CArchive::load);
CArchive arOut(&file,
         CArchive::store);
// use the archives to pass data:
arIn >> dwValue;
arOut << dwValue;




Does this look right for me?
I am confused by the reference to archives.  I don't know what an archive means in this context.

I would happily give 750 points for a working C++ code to send the above query and capture the output to a character buffer.  

Thanks,
  Ken


0
Comment
Question by:klopter
3 Comments
 
LVL 2

Accepted Solution

by:
agriggs earned 100 total points
ID: 6168888
If I understand you correctly, you want to connect to a web page and retrieve the specified html file.  There are many ways to do this.

One way that I have not tried is through the MFC example program TEAR.  Look it up on MSDN.  It is a command-line program that takes a URL as input and writes the html to standard output.  It should give you a pretty good start.

Or you may want to just write a program to drive the TEAR program.

Here you go:

http://msdn.microsoft.com/library/devprods/vs6/visualc/vcsample/_sample_mfc_tear.htm
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6175444
There is a very simple technique to do this in JavaScript (about 10 lines of code -- just double-click the.JS file to run it).  Are you interested in a JavaScript solution?

-- Dan
0
 

Author Comment

by:klopter
ID: 6177493
Thanks.  That looks like just what I need.  I haven't gotten a chance to play with it yet, but it looks perfect for me.

Ken
P.S.  To Dan - I might indeed be interested in a javascript solution.  I'll post another question if I decide to pursue that route.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now