Difference between revisions of "QOTD"
From Lazarus wiki
Jump to navigationJump to search (Please start headings with == to match the rest of the wiki thanks) |
Minesadorada (talk | contribs) m (Small change in code) |
||
Line 35: | Line 35: | ||
MyClient.Logout; | MyClient.Logout; | ||
ShowMessage(szQuote); | ShowMessage(szQuote); | ||
+ | FreeAndNil(MyClient.); | ||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 14:20, 13 October 2014
Quote of the Day
Summary
- Code example of using Synapse to query a public QOTD server
History
Accessing a QOTD server via 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)