Solved

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

Posted on 2001-06-08
3
295 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

771 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

12 Experts available now in Live!

Get 1:1 Help Now