📄 concli1.dpr
字号:
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Author: Fran鏾is PIETTE
Description: ConCli shows how to use TWSocket in a console mode application
(for Delphi 2, Delphi 3 or Delphi 4).
Creation: Nov 20, 1997
Version: 1.01
EMail: http://www.overbyte.be http://www.rtfm.be/fpiette
francois.piette@overbyte.be francois.piette@rtfm.be
francois.piette@pophost.eunet.be
Support: Use the mailing list twsocket@elists.org
Follow "support" link at http://www.overbyte.be for subscription.
Legal issues: Copyright (C) 1997-2002 by Fran鏾is PIETTE
Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56
<francois.piette@overbyte.be>
This software is provided 'as-is', without any express or
implied warranty. In no event will the author be held liable
for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it
and redistribute it freely, subject to the following
restrictions:
1. The origin of this software must not be misrepresented,
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
Updates:
Dec 05, 1998 V1.01 Don't use TWait control anymore
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{$IFDEF VER80}
Bomb('Sorry, Delphi 1 does not support console mode programs');
{$ENDIF}
{$APPTYPE CONSOLE}
program ConCli1;
uses
Forms, WSocket;
var
WSocket1 : TWSocket;
Buffer : String;
begin
WSocket1 := TWsocket.Create(nil);
WSocket1.Proto := 'tcp';
WSocket1.Addr := 'localhost';
WSocket1.Port := 'telnet';
WSocket1.Connect;
{ Connect is asynchronous (non-blocking). We will wait while the }
{ session is connecting or application terminated. }
while WSocket1.State in [wsConnecting] do begin
Application.ProcessMessages;
if Application.Terminated then
break;
end;
if WSocket1.State = wsConnected then begin
WSocket1.ReadLine(15, Buffer);
Writeln('Server banner is: ' + Buffer);
WSocket1.Close;
end
else
Writeln('Connection failed');
WSocket1.Destroy;
Writeln('Hit enter...');
Readln;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -