Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2001-06-08
3
Medium Priority
?
340 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 400 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.
Suggested Courses

885 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