Solved

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

Posted on 2001-06-08
3
332 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

751 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