亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tcpcmd.pas

?? 文件名稱:新曦 我的資源 搜索軟件 源程序(Borland Delphi 7)說明
?? PAS
字號:
{*_* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Author:       Fran鏾is PIETTE
Description:  This code is part of SvcTcp and SrvTcp sample programs. In those
              samples, all TWSocket code has been encapsulated in TTcpDaemon
              object. This is done so that you can see how the same code can
              be used inside a service or inside a normal exe program.
Creation:     July 15, 2000
Version:      1.00
EMail:        http://users.swing.be/francois.piette  francois.piette@swing.be
              http://www.rtfm.be/fpiette             francois.piette@rtfm.be
              francois.piette@pophost.eunet.be
Support:      Use the mailing list twsocket@elists.org
              See http://www.rtfm.be/fpiette/supportuk.htm for subscription.
Legal issues: Copyright (C) 2000 by Fran鏾is PIETTE
              Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56
              <francois.piette@pophost.eunet.be><francois.piette@swing.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.

              4. You must register this software by sending a picture postcard
                 to the author. Use a nice stamp and mention your name, street
                 address, EMail address and any comment you like to say.

History:

 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
unit TcpCmd;

{$B-}           { Enable partial boolean evaluation   }
{$T-}           { Untyped pointers                    }
{$X+}           { Enable extended syntax              }
{$IFNDEF VER80} { Not for Delphi 1                    }
    {$H+}       { Use long strings                    }
    {$J+}       { Allow typed constant to be modified }
{$ENDIF}

interface

uses
  WinTypes, WinProcs, Messages, SysUtils, Classes, WSocket, WSocketS;

const
  TcpCmdVersion             = 100;
  CopyRight    : String     = ' TcpCmd (c) 2000 F. Piette V1.00 ';

type
  { This class is used as a client class for TWSocketServer. Each time a    }
  { client connect to the server, TWSocketServer will instanciate a new     }
  { TTcpSrvClient to handle the client.                                     }
  TTcpSrvClient = class(TWSocketClient)
  public
    RcvdLine    : String;
    Param       : array [0..10] of String;
    ParamCount  : Integer;
    ConnectTime : TDateTime;
  end;

  TDisplayProc = procedure (Msg : String) of object;

  { This class encapsulate all the work for a basic TCP server. It include }
  { a basic command interpreter.                                           }
  TTcpDaemon = class(TObject)
  private
    WSocketServer1 : TWSocketServer;
    FPort          : String;
    FAddr          : String;
    FOnDisplay     : TDisplayProc;
    procedure Display(Msg : String);
    procedure WSocketServer1BgException(Sender: TObject; E: Exception;
                                        var CanClose: Boolean);
    procedure WSocketServer1ClientConnect(Sender: TObject;
                                          Client: TWSocketClient;
                                          Error: Word);
    procedure WSocketServer1ClientDisconnect(Sender: TObject;
                                             Client: TWSocketClient;
                                             Error: Word);
    procedure ClientDataAvailable(Sender: TObject; Error: Word);
    procedure ProcessData(Client: TTcpSrvClient);
    procedure ClientBgException(Sender: TObject; E: Exception;
                                var CanClose: Boolean);
    function  GetBanner: String;
    procedure SetBanner(const Value: String);
  public
    constructor Create; virtual;
    destructor  Destroy; override;
    procedure   Start;
    procedure   Stop;
    property OnDisplay : TDisplayProc read FOnDisplay write FOnDisplay;
    { Make Banner property available to the outside. We could make other    }
    { TWSocket properties available.                                        }
    property Banner : String          read GetBanner  write SetBanner;
    property Port   : String          read FPort      write FPort;
    property Addr   : String          read FAddr      write FAddr;
  end;

implementation


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
constructor TTcpDaemon.Create;
begin
    inherited Create;
    WSocketServer1        := TWSocketServer.Create(nil);
    WSocketServer1.Banner := 'ICS Tcp Service Ready';
    FPort                 := '2120';
    FAddr                 := '0.0.0.0';
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
destructor  TTcpDaemon.Destroy;
begin
    if Assigned(WSocketServer1) then begin
        WSocketServer1.Destroy;
        WSocketServer1 := nil;
    end;
    inherited Destroy;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpDaemon.WSocketServer1BgException(Sender: TObject;
  E: Exception; var CanClose: Boolean);
begin
    Display('Server exception occured: ' + E.ClassName + ': ' + E.Message);
    CanClose := FALSE;  { Hoping that server will still work ! }
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ This event is called each time a new client connect. We can setup our     }
{ client class to fit our needs (We use line mode and two events)           }
procedure TTcpDaemon.WSocketServer1ClientConnect(
    Sender : TObject;
    Client : TWSocketClient;
    Error  : Word);
begin
    with Client as TTcpSrvClient do begin
        Display('Client connecting: ' + PeerAddr);
        LineMode        := TRUE;
        LineEdit        := TRUE;
        OnDataAvailable := ClientDataAvailable;
        OnBgException   := ClientBgException;
        ConnectTime     := Now;
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ This event is called each time a client disconnect. No many things to do  }
{ here. Just display a message.                                             }
procedure TTcpDaemon.WSocketServer1ClientDisconnect(
    Sender : TObject;
    Client : TWSocketClient;
    Error  : Word);
begin
    with Client as TTcpSrvClient do begin
        Display('Client disconnecting: ' + PeerAddr + '   ' +
                'Duration: ' + FormatDateTime('hh:nn:ss',
                Now - ConnectTime));
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpDaemon.ClientDataAvailable(
    Sender : TObject;
    Error  : Word);
begin
    with Sender as TTcpSrvClient do begin
        { We use line mode. We will receive complete lines }
        RcvdLine := ReceiveStr;
        { Remove trailing CR/LF }
        while (Length(RcvdLine) > 0) and
              (RcvdLine[Length(RcvdLine)] in [#13, #10]) do
            RcvdLine := Copy(RcvdLine, 1, Length(RcvdLine) - 1);
        Display('Received from ' + GetPeerAddr + ': ''' + RcvdLine + '''');
        ProcessData(Sender as TTcpSrvClient);
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ Split a command line into an array of words. Use spaces or tabs as        }
{ command delimiter. Commands words have to be delimited by doubles quotes  }
{ if they include spaces or tabs.                                           }
function ParseCommandLine(
    const CmdLine     : String;
    var   ParamsArray : array of string) : Integer;
var
    Index   : Integer;
    I, J    : Integer;
begin
    I      := 1;
    Index  := Low(ParamsArray);
    while (Index <= High(ParamsArray)) and
          (I <= Length(CmdLine)) do begin
        { Skip spaces and tabs }
        while (I <= Length(CmdLine)) and (CmdLine[I] in [' ', #9]) do
            Inc(I);
        if I > Length(CmdLine) then
            break;
        { Check if quoted parameters (can have embeded spaces) }
        if CmdLine[I] = '"' then begin
            Inc(I);
            ParamsArray[Index] := '';
            while I <= Length(CmdLine) do begin
                if CmdLine[I] = '"' then begin
                    if (I >= Length(CmdLine)) or (CmdLine[I + 1] <> '"') then begin
                        Inc(I);
                        break;
                    end;
                    ParamsArray[Index] := ParamsArray[Index] + '"';
                    Inc(I, 2);
                end
                else begin
                    ParamsArray[Index] := ParamsArray[Index] + CmdLine[I];
                    Inc(I);
                end;
            end;
        end
        else begin
            J := I;
            while (I <= Length(CmdLine)) and (not (CmdLine[I] in [' ', #9])) do
                Inc(I);
            if J = I then
                break;
            ParamsArray[Index] := Copy(CmdLine, J, I - J);
        end;
        Inc(Index);
    end;
    Result := Index - Low(ParamsArray);
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ Process a command line received from any client. If process takes time,   }
{ you should use a thread to do the work and return immediately.            }
procedure TTcpDaemon.ProcessData(Client : TTcpSrvClient);
var
    I       : Integer;
    AClient : TTcpSrvClient;
begin
    { Parse command line. }
    Client.ParamCount := ParseCommandLine(Client.RcvdLine, Client.Param);
    if Client.ParamCount <= 0 then
        Exit;

    { We could replace all those CompareText with a table lookup }
    if CompareText(Client.Param[0], 'exit') = 0 then
        { We can't call Client.Close here because we will immediately }
        { reenter DataAvailable event handler with same line because  }
        { a line is removed from buffer AFTER it has been processed.  }
        { Using CloseDelayed will delay Close until we are out of     }
        { current event handler.                                      }
        Client.CloseDelayed
    else if CompareText(Client.Param[0], 'time') = 0 then
        { Send server date and time to client }
        Client.SendStr(DateTimeToStr(Now) + #13#10)
    else if CompareText(Client.Param[0], 'who') = 0 then begin
        { Send client list to client }
        Client.SendStr('There are ' + IntToStr(WSocketServer1.ClientCount) +
                       ' connected users:' + #13#10);
        for I := WSocketServer1.ClientCount - 1 downto 0 do begin
            AClient := TTcpSrvClient(WSocketServer1.Client[I]);
            Client.SendStr(AClient.PeerAddr + ':' + AClient.GetPeerPort + ' ' +
                           DateTimeToStr(AClient.ConnectTime) + #13#10);
        end;
    end
    else if CompareText(Client.Param[0], 'help') = 0 then begin
        Client.SendStr('Commands are:' + #13#10 +
                       '   exit        Close current session' + #13#10 +
                       '   time        Display server time and date' + #13#10 +
                       '   who         Display connected clients' + #13#10 +
                       '   help        Show this help text' + #13#10);
    end
    else begin
        if Client.State = wsConnected then
            Client.SendStr('Unknown command: ''' +
                           Client.Param[0] + '''' + #13#10 +
                           'Type help if you need help...' +#13#10);
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ This event handler is called when a client socket experience a background }
{ exception. It is likely to occurs when client aborted connection and data }
{ has not been sent yet.                                                    }
procedure TTcpDaemon.ClientBgException(
    Sender       : TObject;
    E            : Exception;
    var CanClose : Boolean);
begin
    Display('Client exception occured: ' + E.ClassName + ': ' + E.Message);
    CanClose := TRUE;   { Goodbye client ! }
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpDaemon.Display(Msg: String);
begin
    if Assigned(FOnDisplay) then
        FOnDisplay(Msg);
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpDaemon.Start;
begin
    WSocketServer1.OnBgException      := WSocketServer1BgException;
    WSocketServer1.OnClientConnect    := WSocketServer1ClientConnect;
    WSocketServer1.OnClientDisconnect := WSocketServer1ClientDisconnect;
    WSocketServer1.Proto              := 'tcp';
    WSocketServer1.Port               := FPort;
    WSocketServer1.Addr               := FAddr;
    WSocketServer1.ClientClass        := TTcpSrvClient;
    WSocketServer1.Listen;
    Display('Waiting for clients...');
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpDaemon.Stop;
begin
    WSocketServer1.Close;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function TTcpDaemon.GetBanner: String;
begin
    Result := WSocketServer1.Banner;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpDaemon.SetBanner(const Value: String);
begin
    WSocketServer1.Banner := Value;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}

end.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91久久精品一区二区三区| 国产亚洲制服色| 这里只有精品99re| 中文在线免费一区三区高中清不卡| 9i在线看片成人免费| 欧美一区二区三区四区久久 | 日韩avvvv在线播放| 懂色av中文一区二区三区| 欧美日韩精品一二三区| 亚洲欧美偷拍卡通变态| 国产精品夜夜嗨| 欧美妇女性影城| 一区二区视频在线看| 国产激情一区二区三区四区 | 在线中文字幕一区二区| 精品国产青草久久久久福利| 亚洲精品大片www| 国产69精品久久777的优势| 日韩午夜中文字幕| 性做久久久久久久久| 91蜜桃视频在线| 国产精品无码永久免费888| 久久99精品久久久久久国产越南| 欧美日韩国产经典色站一区二区三区| 亚洲欧洲三级电影| bt7086福利一区国产| 国产日韩精品视频一区| 久草热8精品视频在线观看| 欧美精品1区2区3区| 亚洲国产成人精品视频| 日韩精品久久理论片| 欧美三级中文字幕| 男男成人高潮片免费网站| 亚洲综合色网站| 色哟哟一区二区在线观看| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 国产一区二区三区观看| 久久日韩粉嫩一区二区三区| 国产精品一区2区| 国产欧美日韩三区| bt7086福利一区国产| 亚洲美女精品一区| 欧美三级中文字| 国产成人免费视频| 精品视频999| 日韩电影在线免费观看| 欧美一区2区视频在线观看| 免费在线观看日韩欧美| 337p粉嫩大胆噜噜噜噜噜91av| 极品销魂美女一区二区三区| 久久男人中文字幕资源站| 岛国精品在线观看| 亚洲乱码国产乱码精品精的特点| 欧美午夜影院一区| 久久狠狠亚洲综合| 国产精品无遮挡| 欧美性三三影院| 久久国内精品视频| 国产精品久久久久久亚洲毛片| 91社区在线播放| 偷拍亚洲欧洲综合| 国产亚洲精久久久久久| 午夜久久久久久电影| 精品处破学生在线二十三| 丁香一区二区三区| 亚洲综合在线观看视频| 日韩一区二区三区四区五区六区| 韩国av一区二区三区| 亚洲精品欧美综合四区| 日韩一区二区三区免费看| 从欧美一区二区三区| 日本高清不卡视频| 国产日韩欧美麻豆| 亚洲综合色自拍一区| 99视频一区二区| 亚洲一区二区视频在线| 精品福利在线导航| 色呦呦国产精品| 狠狠色2019综合网| 夜夜嗨av一区二区三区四季av| 久久久久久夜精品精品免费| 91精品办公室少妇高潮对白| 国产一区三区三区| 亚洲电影第三页| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 色嗨嗨av一区二区三区| 久久99国产精品成人| 亚洲一区二区三区视频在线播放| 岛国一区二区三区| 秋霞电影一区二区| 怡红院av一区二区三区| 国产欧美一区二区三区在线看蜜臀 | 日韩免费福利电影在线观看| 国产成人丝袜美腿| 久久91精品久久久久久秒播| 亚洲大片精品永久免费| 亚洲人xxxx| 久久久久久免费| 亚洲精品视频在线观看免费| 欧美色图激情小说| 亚洲理论在线观看| 国产精品婷婷午夜在线观看| 精品国精品自拍自在线| 91精品国产福利| 在线观看国产91| 91浏览器入口在线观看| 99精品视频免费在线观看| 国产精品一区二区三区99| 蜜桃视频一区二区| 麻豆一区二区99久久久久| 午夜av电影一区| 亚洲国产精品久久人人爱蜜臀| 亚洲欧美激情小说另类| 自拍偷拍欧美激情| 亚洲三级免费电影| 亚洲欧美日韩国产另类专区| 自拍偷拍欧美激情| 亚洲黄色性网站| 亚洲尤物视频在线| 欧美人与禽zozo性伦| 欧美日韩另类一区| 欧美日本一区二区三区四区| 欧美乱妇15p| 欧美精品777| 欧美一区二区三区视频| 欧美v亚洲v综合ⅴ国产v| 精品国产免费人成电影在线观看四季| 欧美精品123区| 欧美成人午夜电影| 欧美高清在线一区二区| 综合在线观看色| 一区二区三区在线视频播放| 亚洲在线观看免费视频| 肉色丝袜一区二区| 国产麻豆91精品| 国产真实乱子伦精品视频| 国产精品一品视频| 偷拍一区二区三区| 韩国女主播一区| 国产精品亚洲视频| 久久久久国产精品麻豆| 亚洲成人午夜电影| 欧美三级中文字幕在线观看| 91精品国产综合久久精品图片| 日韩欧美精品在线视频| 欧美激情一区二区三区| 亚洲女人****多毛耸耸8| 日韩精品五月天| 国产福利一区二区三区视频在线| 91一区二区三区在线播放| 欧美高清视频一二三区| 久久久www成人免费无遮挡大片| 国产精品丝袜一区| 日韩精品欧美精品| 成人美女视频在线看| 午夜精彩视频在线观看不卡| 久久福利视频一区二区| 99re热这里只有精品免费视频| 欧美高清视频www夜色资源网| 亚洲精品一区二区精华| 亚洲欧美激情在线| 国产传媒欧美日韩成人| 欧美亚洲一区二区三区四区| 久久久精品日韩欧美| 亚洲高清免费一级二级三级| 国产精品一二三在| 欧美久久婷婷综合色| 中文字幕一区二区在线观看| 日韩av一二三| 91麻豆免费在线观看| 久久久久久久性| 午夜成人免费电影| 欧美一区二区三区四区五区| 欧美成人bangbros| 亚洲国产综合在线| 成a人片国产精品| 日韩欧美资源站| 亚洲国产欧美日韩另类综合 | 久久精品国产免费看久久精品| 91猫先生在线| 亚洲国产高清aⅴ视频| 久久精品国内一区二区三区| 91久久国产最好的精华液| 国产精品人人做人人爽人人添| 麻豆精品视频在线观看视频| 欧美性猛交一区二区三区精品| 国产精品国产三级国产普通话99| 91视视频在线观看入口直接观看www | 另类人妖一区二区av| 欧美视频一区二区| 欧美自拍偷拍午夜视频| 国产精品麻豆欧美日韩ww| 国产激情一区二区三区四区| 久久一留热品黄| 免费在线观看成人| 欧美一二三区在线观看| 日本亚洲视频在线| 这里只有精品视频在线观看| 日韩精品久久久久久| 91精品国模一区二区三区|