Jump to content
Ian Branch

Quote of the Day...

Recommended Posts

Hi Team,

D10.3.3, Indy v 10.

I am trying to implement the Quote of the Day example as demonstrated by Alister Christie in his video 'Quote of the Day (And tray icon balloon hint)' in 2008.

The project builds OK and aside from changing the idQOTD port to 80 it seems to run OK using quotes4all.net as the host, but doesn't seemingly return anything.

This is my first foray into Indy.

I suspected it may be a Unicode thing however it doesn't seemingly return anything when built with D2007 either.

I can't tell what version of Indy Alister used but I suspect it was earlier than 10.

Has anybody got this particular example working in the more recent Delphis/Indys?

I'd appreciate any suggestions/assistance/guidance.

Regards,

Ian

Share this post


Link to post
1 hour ago, Ian Branch said:

I am trying to implement the Quote of the Day example as demonstrated by Alister Christie in his video 'Quote of the Day (And tray icon balloon hint)' in 2008.

The project builds OK and aside from changing the idQOTD port to 80 it seems to run OK using quotes4all.net as the host, but doesn't seemingly return anything.

TIdQOTD implements the "Quote of the Day" protocol described in RFC 865.  It connects to a QOTD server on port 17, grabs all of the raw bytes the server provides until the server closes the connection, and then returns the raw bytes as a string.

 

But you are not connecting to a real QOTD server on "quotes4all.net".  When you changed the TIdQOTD.Port property from 17 to 80, you are connecting to an HTTP server on "quotes4all.net" instead, and as such it requires an HTTP client rather than a QOTD client.  You are not seeing any data being returned because TIdQOTD is not requesting any data, and eventually the HTTP server closes the connection when it does not receive a valid HTTP request.

 

In Alister's demo, he connects to real QOTD servers for "alpha.mike-r.com" and "quotes4all.net" on port 17 only, not on port 80.  The QOTD server on "alpha.mike-r.com" still works (I just tried it), but it does not appear that there is a QOTD server running at "quotes4all.net" on port 17 anymore (or maybe it is just offline right now, who knows. Alister's demo is over a decade old, after all).

 

So, if you want to use TIdQOTD, you need to connect to a real QOTD server, like the one at "alpha.mike-r.com".  If you want to use "quotes4all.net" then you need to use TIdHTTP instead of TIdQOTD, eg:

uses
  ..., IdHTTP;
  
var
  HTTP: TIdHTTP;
  Quote: string;
begin
  HTTP := TIdHTTP.Create;
  try
    Quote := HTTP.Get('http://quotes4all.net');
  finally
    HTTP.Free;
  end;
end;

Just know that you are going to get more data than you are expecting, since quotes4all's HTTP server delivers content in HTML format, which you will have to parse afterwards to extract the text you want.

Edited by Remy Lebeau
  • Like 1

Share this post


Link to post

Just trying TIdQOTD and all I get now is Socket Error #10061 Connection refused.

 

Host: alpha.mike-r.com

Port: 17

 

ANy thoughts as to why - maybe this host is no longer available, if so is there another?

Share this post


Link to post
4 hours ago, bazzer747 said:

maybe this host is no longer available

Seems to be.  I can't access anything on alpha.mike-r.com, so it must be down.

4 hours ago, bazzer747 said:

if so is there another?

I'm sure you can find another QOTD server online somewhere.  There are a few mentioned on the bottom on https://wiki.freepascal.org/QOTD, for instance.  Just look around.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×