jeffbmartinez (31) Here are some pointers on what you're going to want to read more about to get this job done: You will want to learn about sockets. Sockets will be your portals to the internet. These are what you will use to send and receive data from the internet. If you are on Windows, you want to check out winsock (#include <winsock2.h>). Important: You will need to link to ws2_32.lib to make this compile. If you're getting a ton of linker errors, you probably forgot to include ws2_32.lib in your project. Possible search keywords: winsock, berkeley sockets, network programming. nullterminator.net has a decent c++ tutorial demonstrating a simple client and server application using winsock (http://www.nullterminator.net/winsock.html). You will be building a client that connects to whatever server is providing your stocks. Once you can send and receive data from the internet, you will need to know how to speak the language of whatever service you're contacting. These languages are called protocols. If you're contacting a website for the stock information, odds are that website will use HTTP (HyperText Transfer Protocol). See "HTTP Made Really Easy" at jmarshall.com for a good tutorial on http (http://www.jmarshall.com/easy/http/). Search for: Http, get request, post request If you're doing this stuff for fun/knowledge, you should follow the above steps. If you're just trying to get something done for work or as quickly as possible, find a library that will do what you want. I have never used it myself, but the C++ Poco libraries include a HTTPClient object which should get you around the sockets and the http part. Last thing I'll mention is to make sure that the stock service you're using allows you to grab their information for free. Certain services' terms of service don't allow you to write your own program to grab info from their servers (Try writing a program to search on Google without their permission, for example). |
SigmaSecurity (9) Well for one thing, the way that you should do this is definitly with the Win32 API, but there are some better alternatives to WinSock. For starters you should look into the WinInet API. This is basically some WinSock-like code wrapped up in a handfull of nice functions. There are a couple of advantages though. 1.) Easier to use than WinSock (too many send() and recv()'s everywhere) 2.) Has built in support for HTTP, HTTPS, FTP, and Gopher protocols (will manage HTTPS' SSL for you) 3.) Easy to parse things such as status codes, header values, and even cookies So look into these pages: http://msdn.microsoft.com/en-us/library/aa385483(VS.85).aspx http://www.differentpla.net/content/2004/02/downloading-from-an-http-server-using-wininet and see if it suits your needs. Hope that this helps SigmaSecurity |
Should I use sockets or this thing about API? |