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

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

?? tcpsrv1.pas

?? 包含常用Internet協議TCP,UDP、HTTP、FTP、Telnet等
?? PAS
字號:
{*_* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Author:       Fran鏾is Piette
Creation:     Aug 29, 1999
Version:      1.01
Description:  Basic TCP server showing how to use TWSocketServer and
              TWSocketClient components.
EMail:        francois.piette@pophost.eunet.be    francois.piette@rtfm.be
              francois.piette@swing.be            http://www.rtfm.be/fpiette
Support:      Use the mailing list twsocket@rtfm.be See website for details.
Legal issues: Copyright (C) 1999-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:
Sep 05, 1999 V1.01 Adapted for Delphi 1

 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
unit TcpSrv1;

interface

uses
  WinTypes, WinProcs, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, IniFiles, StdCtrls, ExtCtrls, WSocket, WSocketS;

const
  WM_APPSTARTUP      = WM_USER + 1;

type
  { TTcpSrvClient is the class which will be instanciated by server component }
  { for each new client. N simultaneous clients means N TTcpSrvClient will be }
  { instanciated. Each being used to handle only a single client.             }
  { We can add any data that has to be private for each client, such as       }
  { receive buffer or any other data needed for processing.                   }
  TTcpSrvClient = class(TWSocketClient)
  public
    RcvdLine    : String;
    ConnectTime : TDateTime;
  end;

  TTcpSrvForm = class(TForm)
    ToolPanel: TPanel;
    DisplayMemo: TMemo;
    WSocketServer1: TWSocketServer;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure WSocketServer1ClientConnect(Sender: TObject;
      Client: TWSocketClient; Error: Word);
    procedure WSocketServer1ClientDisconnect(Sender: TObject;
      Client: TWSocketClient; Error: Word);
    procedure WSocketServer1BgException(Sender: TObject; E: Exception;
      var CanClose: Boolean);
  private
    FIniFileName : String;
    FInitialized : Boolean;
    procedure Display(Msg : String);
    procedure WMAppStartup(var Msg: TMessage); message WM_APPSTARTUP;
    procedure ClientDataAvailable(Sender: TObject; Error: Word);
    procedure ProcessData(Client : TTcpSrvClient);
    procedure ClientBgException(Sender       : TObject;
                                E            : Exception;
                                var CanClose : Boolean);
  public
    property IniFileName : String read FIniFileName write FIniFileName;
  end;

var
  TcpSrvForm: TTcpSrvForm;

implementation

{$R *.DFM}

const
    SectionWindow      = 'WindowTcpSrv';
    KeyTop             = 'Top';
    KeyLeft            = 'Left';
    KeyWidth           = 'Width';
    KeyHeight          = 'Height';


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpSrvForm.FormCreate(Sender: TObject);
begin
    { Compute INI file name based on exe file name. Remove path to make it  }
    { go to windows directory.                                              }
    FIniFileName := LowerCase(ExtractFileName(Application.ExeName));
    FIniFileName := Copy(FIniFileName, 1, Length(FIniFileName) - 3) + 'ini';
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpSrvForm.FormShow(Sender: TObject);
var
    IniFile : TIniFile;
begin
    if not FInitialized then begin
        FInitialized := TRUE;

        { Fetch persistent parameters from INI file }
        IniFile      := TIniFile.Create(FIniFileName);
        Width        := IniFile.ReadInteger(SectionWindow, KeyWidth,  Width);
        Height       := IniFile.ReadInteger(SectionWindow, KeyHeight, Height);
        Top          := IniFile.ReadInteger(SectionWindow, KeyTop,
                                            (Screen.Height - Height) div 2);
        Left         := IniFile.ReadInteger(SectionWindow, KeyLeft,
                                            (Screen.Width  - Width)  div 2);
        DisplayMemo.Clear;
        IniFile.Destroy;
        { Delay startup code until our UI is ready and visible }
        PostMessage(Handle, WM_APPSTARTUP, 0, 0);
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpSrvForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
    IniFile : TIniFile;
begin
    { Save persistent data to INI file }
    IniFile := TIniFile.Create(FIniFileName);
    IniFile.WriteInteger(SectionWindow, KeyTop,         Top);
    IniFile.WriteInteger(SectionWindow, KeyLeft,        Left);
    IniFile.WriteInteger(SectionWindow, KeyWidth,       Width);
    IniFile.WriteInteger(SectionWindow, KeyHeight,      Height);
    IniFile.Destroy;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ Display a message in our display memo. Delete lines to be sure to not     }
{ overflow the memo which may have a limited capacity.                      }
procedure TTcpSrvForm.Display(Msg : String);
var
    I : Integer;
begin
    DisplayMemo.Lines.BeginUpdate;
    try
        if DisplayMemo.Lines.Count > 200 then begin
            for I := 1 to 50 do
                DisplayMemo.Lines.Delete(0);
        end;
        DisplayMemo.Lines.Add(Msg);
    finally
        DisplayMemo.Lines.EndUpdate;
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ This is our custom message handler. We posted a WM_APPSTARTUP message     }
{ from FormShow event handler. Now UI is ready and visible.                 }
procedure TTcpSrvForm.WMAppStartup(var Msg: TMessage);
begin
    WSocketServer1.Proto       := 'tcp';         { Use TCP protocol  }
    WSocketServer1.Port        := 'telnet';      { Use telnet port   }
    WSocketServer1.Addr        := '0.0.0.0';     { Use any interface }
    WSocketServer1.ClientClass := TTcpSrvClient; { Use our component }
    WSocketServer1.Listen;                       { Start litening    }
    Display('Waiting for clients...');
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpSrvForm.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;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpSrvForm.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 TTcpSrvForm.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;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTcpSrvForm.ProcessData(Client : TTcpSrvClient);
var
    I       : Integer;
    AClient : TTcpSrvClient;
begin
    { We could replace all those CompareText with a table lookup }
    if CompareText(Client.RcvdLine, '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.RcvdLine, 'time') = 0 then
        { Send server date and time to client }
        Client.SendStr(DateTimeToStr(Now) + #13#10)
    else if CompareText(Client.RcvdLine, '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.RcvdLine, 'exception') = 0 then
        { This will trigger a background exception for client }
        PostMessage(Client.Handle, WM_TRIGGER_EXCEPTION, 0, 0)
    else
        if Client.State = wsConnected then
            Client.SendStr('Unknown command: ''' + Client.RcvdLine + '''' + #13#10);
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ This event handler is called when listening (server) socket experienced   }
{ a background exception. Should normally never occurs.                     }
procedure TTcpSrvForm.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 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 TTcpSrvForm.ClientBgException(
    Sender       : TObject;
    E            : Exception;
    var CanClose : Boolean);
begin
    Display('Client exception occured: ' + E.ClassName + ': ' + E.Message);
    CanClose := TRUE;   { Goodbye client ! }
end;


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

end.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美大片在线观看一区二区| 亚洲午夜免费电影| 亚洲精品视频在线看| 蜜臀久久久99精品久久久久久| 99久久综合99久久综合网站| 日韩三级av在线播放| 一区二区三区色| 99在线精品观看| 国产欧美日韩在线看| 美女视频免费一区| 在线视频欧美区| 国产精品嫩草影院com| 精品无人区卡一卡二卡三乱码免费卡| 色域天天综合网| 亚洲欧洲日产国码二区| 国产电影一区在线| 精品国产露脸精彩对白| 日韩专区中文字幕一区二区| 在线视频中文字幕一区二区| 综合久久久久久久| 成人午夜av在线| 国产午夜精品久久| 国产成人99久久亚洲综合精品| 精品三级在线观看| 国产综合成人久久大片91| 欧美一二区视频| 毛片基地黄久久久久久天堂| 91.com视频| 日韩av高清在线观看| 91精品国产一区二区三区蜜臀| 亚洲大片精品永久免费| 欧美日韩精品一区二区三区蜜桃| 亚洲欧洲中文日韩久久av乱码| 99re视频这里只有精品| 日韩理论片中文av| 在线观看av一区二区| 一区二区三区91| 欧美日韩久久久久久| 亚洲国产成人tv| 日韩一区二区三免费高清| 九一九一国产精品| 欧美激情一区二区三区在线| 99视频精品全部免费在线| 亚洲激情在线激情| 在线综合+亚洲+欧美中文字幕| 美女在线观看视频一区二区| 欧美r级在线观看| 不卡一区在线观看| 亚洲制服欧美中文字幕中文字幕| 欧美老年两性高潮| 经典三级在线一区| 亚洲欧美一区二区在线观看| 欧美日韩你懂得| 激情欧美一区二区三区在线观看| 欧美高清在线一区二区| 色婷婷激情久久| 美女视频黄久久| 中文字幕一区二区视频| 精品视频一区三区九区| 国产一区在线观看麻豆| 亚洲欧美国产77777| 91精品国产综合久久福利软件| 国产一区视频网站| 亚洲综合偷拍欧美一区色| 日韩欧美一区二区视频| 成人av网址在线| 日欧美一区二区| 国产女人aaa级久久久级| 在线观看免费视频综合| 国产中文字幕一区| 亚洲国产一区二区三区| 国产日韩欧美激情| 欧美精品tushy高清| 成人国产精品免费观看动漫| 五月天视频一区| 中文字幕二三区不卡| 91精品国产91综合久久蜜臀| 成人国产亚洲欧美成人综合网| 天堂在线一区二区| 亚洲欧美另类久久久精品| 欧美大片一区二区三区| 欧洲国内综合视频| av福利精品导航| 青青草国产精品97视觉盛宴 | 国产精品免费网站在线观看| 欧美日韩的一区二区| 不卡视频在线观看| 韩日精品视频一区| 蜜桃视频一区二区| 亚洲chinese男男1069| 综合久久一区二区三区| 国产亚洲综合在线| 精品精品国产高清一毛片一天堂| 91精彩视频在线| 不卡av电影在线播放| 国产剧情av麻豆香蕉精品| 亚洲国产一区二区a毛片| 亚洲人成在线观看一区二区| 国产欧美一区二区精品性| 精品成a人在线观看| 日韩欧美国产1| 欧美精品v国产精品v日韩精品 | 国产成人精品1024| 久久99精品国产麻豆不卡| 青青草国产精品亚洲专区无| 亚洲一区二区三区四区五区黄| 中文字幕一区二区三区四区| 国产欧美一二三区| 久久久www免费人成精品| 精品国精品自拍自在线| 日韩精品一区二区三区视频在线观看 | 亚洲欧洲精品成人久久奇米网| 亚洲精品一区二区三区蜜桃下载 | 92精品国产成人观看免费| 国产成+人+日韩+欧美+亚洲| 麻豆国产欧美日韩综合精品二区| 亚洲va韩国va欧美va| 亚洲成人资源在线| 日韩精品一卡二卡三卡四卡无卡| 亚洲国产毛片aaaaa无费看| 亚洲一二三区不卡| 日韩激情视频在线观看| 美国av一区二区| 国产精品资源网站| av资源网一区| 欧美三级电影一区| 日韩视频免费观看高清在线视频| 欧美一区二区三区视频免费| 欧美mv日韩mv国产| 国产欧美中文在线| 亚洲伦理在线精品| 日本欧美一区二区| 国产精品综合二区| 色婷婷综合久久久久中文| 欧美亚洲一区三区| 555www色欧美视频| 久久久久久99久久久精品网站| 久久蜜桃一区二区| 亚洲精品免费播放| 蜜桃av一区二区在线观看| 国产成人激情av| 欧美视频在线不卡| 亚洲精品一区二区在线观看| 国产精品久久久久久久久免费樱桃| 一区二区三区视频在线观看| 日本va欧美va欧美va精品| 成人妖精视频yjsp地址| 欧美三级中文字幕在线观看| 日韩午夜激情电影| 亚洲色欲色欲www在线观看| 日韩电影在线一区| 丰满白嫩尤物一区二区| 欧美三级三级三级| 亚洲国产精品二十页| 香蕉av福利精品导航| 国产九色sp调教91| 欧美日韩美女一区二区| 久久久精品欧美丰满| 亚洲高清久久久| 成人动漫一区二区| 日韩一区二区三区av| 亚洲激情自拍偷拍| 国产精品一区二区在线播放| 欧洲另类一二三四区| 国产精品丝袜黑色高跟| 男女视频一区二区| 在线观看日产精品| 国产精品美女视频| 国产精品一区在线| 日韩亚洲欧美在线| 亚洲一区在线观看视频| 国产成人精品免费| 91精品国产一区二区三区蜜臀| 亚洲免费在线观看视频| 成人一区二区三区视频在线观看 | 欧美日韩精品系列| 自拍偷拍欧美激情| 高清国产一区二区三区| 日韩免费视频线观看| 亚洲大型综合色站| 日本国产一区二区| **性色生活片久久毛片| 国产一区不卡视频| 26uuu国产电影一区二区| 日本91福利区| 欧美一二三四在线| 日韩va欧美va亚洲va久久| 欧美日韩中文另类| 亚洲永久免费av| 在线免费观看不卡av| 亚洲人成网站在线| 95精品视频在线| 亚洲欧美激情视频在线观看一区二区三区 | 日本大香伊一区二区三区| 中文字幕不卡一区| 不卡的av在线| 综合久久综合久久| 一本久道久久综合中文字幕| 亚洲人成在线观看一区二区| 色综合久久久久综合99|