Solved

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

Posted on 2001-06-08
3
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
  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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

617 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