Page 2 of 2

Re: C++ reading info from a webpage

Posted: Sun Jun 13, 2010 3:58 pm
by JamesM
GhostXoPCorp wrote:i want my program to read just a line of information from a cite, for example a "daily update" and just have my program copy that information like this


http://www.examplesite.com

webpage:

Daily Update: First Day Of Program Release

end of webpage
thats all the site willl display

how can i get my C++ win32 program to read that line from that site?
Why not use a language and toolset suited to the task?

Re: C++ reading info from a webpage

Posted: Sun Jun 13, 2010 4:27 pm
by Gigasoft
On Windows, it doesn't get much simpler than using the InternetOpen, InternetOpenUrl and InternetReadFile functions. It basically takes care of everything for you.

Re: C++ reading info from a webpage

Posted: Mon Jun 14, 2010 2:14 am
by Solar
Absolutely +1 to Gigasoft. Nothing beats somebody actually answering the question (how to do it in C++ using Windows API).

Re: C++ reading info from a webpage

Posted: Mon Jun 14, 2010 5:15 am
by Owen
Gigasoft wrote:Send won't return until it has sent everything or it fails, unless the socket is set to non-blocking mode. Recv, however, may return less data than requested.
Not the case, though I understand that the wording of the relevant man pages can be ambiguous.
If space is not available at the sending socket to hold the message to be transmitted, and the socket file descriptor does not have O_NONBLOCK set, send() shall block until space is available. If space is not available at the sending socket to hold the message to be transmitted, and the socket file descriptor does have O_NONBLOCK set, send() shall fail. The select() and poll() functions can be used to determine when it is possible to send more data. [SUS3]
So, indeed send will wait for buffer space to be available. However, for TCP it doesn't guarantee that the whole buffer you pass to send will be sent in one go. You must check the return value and manually ensure this.