Difference between revisions of "QOTD"
From Lazarus wiki
Jump to navigationJump to searchMinesadorada (talk | contribs) m (Small change in code) |
m (Fixed syntax highlighting) |
||
Line 1: | Line 1: | ||
− | + | =Quote of the Day= | |
− | + | ||
− | * Code example of using Synapse to query a public QOTD server | + | ==Summary== |
− | + | ||
+ | * Code example of using Synapse to query a public QOTD server. | ||
+ | |||
+ | ==History== | ||
+ | |||
[http://en.wikipedia.org/wiki/QOTD A wiki article about QOTD] | [http://en.wikipedia.org/wiki/QOTD A wiki article about QOTD] | ||
− | + | ||
− | * You need to download and compile the Synapse package | + | ==Accessing a QOTD server with Lazarus== |
+ | |||
+ | * You need to download and compile the [[Synapse|Synapse package]] | ||
* Put '''tlntsend''' in your Implementation/Uses clause | * Put '''tlntsend''' in your Implementation/Uses clause | ||
* You will be using the QOTD port #17 | * You will be using the QOTD port #17 | ||
− | <syntaxhighlight> | + | |
+ | <syntaxhighlight lang=pascal> | ||
procedure DisplayQOTD; | procedure DisplayQOTD; | ||
Var | Var | ||
Line 15: | Line 22: | ||
begin | begin | ||
− | MyClient:=TTelNetSend.Create; | + | MyClient := TTelNetSend.Create; |
With MyClient do | With MyClient do | ||
begin | begin | ||
− | TargetPort:='17'; | + | TargetPort := '17'; |
Timeout:=3000; | Timeout:=3000; | ||
− | TargetHost:='alpha.mike-r.com'; | + | TargetHost := 'alpha.mike-r.com'; |
end; | end; | ||
If MyClient.Login then | If MyClient.Login then | ||
begin | begin | ||
− | szQuote:=MyClient.RecvString; | + | szQuote := MyClient.RecvString; |
If szQuote = '' then | If szQuote = '' then | ||
begin | begin | ||
MyClient.Send(LineEnding + LineEnding); | MyClient.Send(LineEnding + LineEnding); | ||
− | szQuote:=MyClient.RecvString; | + | szQuote := MyClient.RecvString; |
end; | end; | ||
end | end | ||
Line 38: | Line 45: | ||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
===QOTD Servers=== | ===QOTD Servers=== | ||
− | |||
− | |||
− | qotd.atheistwisdom.com | + | Here are some public QOTD servers: |
+ | |||
+ | * qotd.nngn.net | ||
+ | * qotd.atheistwisdom.com | ||
+ | * djxmmx.net | ||
+ | * alpha.mike-r.com | ||
− | + | Windows users can install the 'Simple TCPIP services' and activate the Windows built-in QOTD server (localhost) | |
− | + | [[Category:Lazarus]] | |
− | + | [[Category:Code Snippets]] | |
− | [[ | ||
− | [[Category:Code]] |
Revision as of 13:42, 23 February 2020
Quote of the Day
Summary
- Code example of using Synapse to query a public QOTD server.
History
Accessing a QOTD server with Lazarus
- You need to download and compile the Synapse package
- Put tlntsend in your Implementation/Uses clause
- You will be using the QOTD port #17
procedure DisplayQOTD;
Var
MyClient:TTelnetSend;
szQuote:String;
begin
MyClient := TTelNetSend.Create;
With MyClient do
begin
TargetPort := '17';
Timeout:=3000;
TargetHost := 'alpha.mike-r.com';
end;
If MyClient.Login then
begin
szQuote := MyClient.RecvString;
If szQuote = '' then
begin
MyClient.Send(LineEnding + LineEnding);
szQuote := MyClient.RecvString;
end;
end
else szQuote:='Could not retrieve quote';
MyClient.Logout;
ShowMessage(szQuote);
FreeAndNil(MyClient.);
end;
QOTD Servers
Here are some public QOTD servers:
- qotd.nngn.net
- qotd.atheistwisdom.com
- djxmmx.net
- alpha.mike-r.com
Windows users can install the 'Simple TCPIP services' and activate the Windows built-in QOTD server (localhost)