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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? mtsrv1.pas

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

Author:       Fran鏾is PIETTE
Description:  This little application shows how to use the TWSocket in a
              multithreaded application. It is a very basic telnet server.
              Each time a client connect to the server, he receive an "hello"
              message. Then every character sent is echoed back to the client.
              There are two units is this application: one for the main
              server code, and one for the client thread.
              Each time a client connect to the server, a new TWSocket is
              created and a new thread is launched to handle the client
              work. When the client disconnect, the TWSocket and the thread
              are destroyed.
              To see this demo working on your computer, start the demo then
              start several copies of the TELNET client program (the one which
              comes with Windows 95 is perfect). Then using each telnet, connect
              to 127.0.0.1. You'll see a new connection in the list box. You
              must receive the "hello" message and see each character as you
              type them. You can use the Disconnect button from the application
              or from the telnet client to see what happends (the connection
              should be closed).
Note:         I made this multithreaded application because so many people
              asked for a multithreaded sample program. Most people think they
              must go multithread in order to simultaneously server several
              clients. This is completely WRONG, specially with TWSocket which
              is a ASYNCHONOUS (non-blocking) component. You can serve as many
              simultaneous clients as you like without using threads ! See how
              TnSrv or ConSrv demo program does it without using threads.
              Multithreaded programs are actually SLOWER and much more difficult
              to develop than event driven, asynchonous programs such as TnSrv
              and ConSrv demos. You need thread only if your server must do
              some blocking and lengthy tasks, such as querying a database. But
              threads are only needed for processing, not for telecommunication
              using TWSocket. TWSocket does send and receive in the background,
              even with no thread.
Creation:     September 21, 1997
Version:      1.02
EMail:        francois.piette@pophost.eunet.be
              francois.piette@rtfm.be             http://www.rtfm.be/fpiette
Support:      Use the mailing list twsocket@rtfm.be See website for details.
Legal issues: Copyright (C) 1997, 1998 by Fran鏾is PIETTE
              Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56
              <francois.piette@pophost.eunet.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.

Updates:
Nov 18, 1997  V1.01 Corrected isxdigit (By Paul Taylor <paul@star.net.au>)
Apr 26, 1998  V1.02 MultiThreaded property correctly setup to TRUE.

 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
unit mtsrv1;

interface

{$IFDEF VER80}
  'This sample program use threads and hence is not compatible with Delphi 1';
{$ENDIF}

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  WSocket, MtSrv2, StdCtrls;

type
  TServerForm = class(TForm)
    ServerWSocket: TWSocket;
    DisconnectButton: TButton;
    QuitButton: TButton;
    ClientListBox: TListBox;
    DisconnectAllButton: TButton;
    procedure ServerWSocketSessionAvailable(Sender: TObject; Error: Word);
    procedure FormShow(Sender: TObject);
    procedure DisconnectButtonClick(Sender: TObject);
    procedure QuitButtonClick(Sender: TObject);
    procedure DisconnectAllButtonClick(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    procedure ClientThreadTerminate(Sender: TObject);
    procedure DisconnectAll;
  end;

var
  ServerForm: TServerForm;

implementation

{$R *.DFM}


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ Check if a character is a valid hex digit                                 }
function isxdigit(Ch : char) : Boolean;
begin
    Result := (ch in ['0'..'9']) or (ch in ['a'..'f']) or (ch in ['A'..'F']);
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ Convert an hexdigit to an integer                                         }
function xdigit(Ch : char) : Integer;
begin
    if ch in ['0'..'9'] then
        Result := ord(Ch) - ord('0')
    else
        Result := (ord(Ch) and 15) + 9;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ Convert the ascii representation of a hex number to an integer            }
function htoi(value : PChar) : Integer;
var
    i : Integer;
begin
    Result := 0;
    i      := 0;
    while (Value[i] <> #0) and (Value[i] = ' ') do
        i := i + 1;
    while (Value[i] <> #0) and (isxDigit(Value[i])) do begin
        Result := Result * 16 + xdigit(Value[i]);
        i := i + 1;
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ This event is generated when a client is connecting                       }
procedure TServerForm.ServerWSocketSessionAvailable(Sender: TObject;
  Error: Word);
var
    ClientThread  : TClientThread;
begin
    { Create a new thread to handle client request                          }
    ClientThread             := TClientThread.Create(ServerWSocket.Accept);

    { Assign the thread's OnTerminate event                                 }
    ClientThread.OnTerminate := ClientThreadTerminate;

    { Add the thread to the listbox which is our client list                }
    ClientListBox.Items.Add(IntToHex(Integer(ClientThread), 8));

    { Then start the client thread work                                     }
    { because it was created in the blocked state                           }
    ClientThread.Resume;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TServerForm.FormShow(Sender: TObject);
const
    FirstTime : Boolean = TRUE;
begin
    if FirstTime then begin
        FirstTime           := FALSE;
        ServerWSocket.Proto := 'tcp';      { We use a TCP connection        }
        ServerWSocket.Port  := 'telnet';   { We wants to use telnet         }
        ServerWSocket.Addr  := '0.0.0.0';  { We accept any client           }
        ServerWSocket.Listen;              { Start server accepting         }
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ This event is generated when the user clicks on the 'Disconnect' button   }
{ when he wants to disconnect the selected client in the listbox.           }
procedure TServerForm.DisconnectButtonClick(Sender: TObject);
var
    ClientThread  : TClientThread;
    Buf           : String;
begin
    { No selected item, nothing to do                                       }
    if ClientListBox.ItemIndex < 0 then
        Exit;

    { Extract the ClientThread pointer from the list box                    }
    Buf := ClientListBox.Items[ClientListBox.ItemIndex];
    ClientThread := TClientThread(htoi(PChar(Buf)));

    { Call ClientThread.Release which will stop the thread                  }
    { In consequence, the OnTerminate event will be generated               }
    ClientThread.Release;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ This event handler is called when one of the client thread terminate      }
{ We will find this thread in our listbox, remove it and destroy the        }
{ TWSocket object use by the corresponding client.                          }
procedure TServerForm.ClientThreadTerminate(Sender: TObject);
var
    ClientThread  : TClientThread;
    Buf           : String;
    Index         : Integer;
begin
    { A thread has been terminated, remove it from our list and destroy     }
    { the ClientWSocket we passed to the thread.                            }
    for Index := 0 to ClientListBox.Items.Count - 1 do begin
        Buf := ClientListBox.Items[Index];
        ClientThread := TClientThread(htoi(PChar(Buf)));
        if ClientThread = TClientThread(Sender) then begin
            { Remove the client from our listbox                            }
            ClientListBox.Items.Delete(Index);
            Break;
        end;
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ This procedure scan the listbox and halt every ClientThread               }
procedure TServerForm.DisconnectAll;
var
    ClientThread  : TClientThread;
    Buf           : String;
begin
    while ClientListBox.Items.Count > 0 do begin
        Buf          := ClientListBox.Items[0];
        ClientThread := TClientThread(htoi(PChar(Buf)));
        ClientThread.Release;
        Application.ProcessMessages;
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TServerForm.QuitButtonClick(Sender: TObject);
begin
    Close;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TServerForm.DisconnectAllButtonClick(Sender: TObject);
begin
    DisconnectAll;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TServerForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
    DisconnectAll;
end;


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

end.

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜成人免费电影| 精品国产一区二区亚洲人成毛片| 国产精品久久久久久久久动漫| 黄色成人免费在线| 国产欧美日韩久久| hitomi一区二区三区精品| 亚洲激情综合网| 欧美喷潮久久久xxxxx| 人人狠狠综合久久亚洲| 精品国产乱码久久久久久闺蜜| 狠狠色丁香九九婷婷综合五月| 国产欧美一区在线| 色国产综合视频| 日韩成人午夜电影| 国产亚洲成年网址在线观看| 91丨九色porny丨蝌蚪| 亚洲高清不卡在线观看| 欧美xxxx在线观看| 99免费精品视频| 日本成人中文字幕在线视频| 日本一区二区三区在线不卡 | 美女视频网站黄色亚洲| 久久亚洲春色中文字幕久久久| a亚洲天堂av| 奇米亚洲午夜久久精品| 亚洲国产高清在线| 欧美顶级少妇做爰| 成人国产电影网| 天堂成人国产精品一区| 欧美国产成人精品| 欧美日高清视频| 成人午夜私人影院| 蜜桃免费网站一区二区三区| 国产精品久久午夜夜伦鲁鲁| 欧美午夜在线一二页| 狠狠色丁香久久婷婷综合丁香| 一区二区三区在线免费播放| 久久一二三国产| 欧美色综合天天久久综合精品| 国产精品一区二区在线观看不卡| 亚洲激情图片小说视频| 国产日韩欧美电影| 日韩亚洲欧美成人一区| 一本在线高清不卡dvd| 国产专区欧美精品| 免费三级欧美电影| 亚洲高清免费一级二级三级| 国产精品美女一区二区| 日韩欧美激情在线| 欧美日韩精品免费观看视频| 成人av免费在线播放| 狠狠色伊人亚洲综合成人| 日韩在线一二三区| 亚洲激情综合网| 亚洲人成亚洲人成在线观看图片| 亚洲精品在线网站| 日韩一区二区三区四区| 欧美日韩精品一区视频| 欧美性生交片4| 一本一道久久a久久精品| 成人开心网精品视频| 国产一区二区三区精品欧美日韩一区二区三区 | 色婷婷综合久久久久中文| 成人在线一区二区三区| 国产精品996| 国产精品综合视频| 国内精品国产成人国产三级粉色 | 久久精品欧美一区二区三区不卡| 69av一区二区三区| 欧美日韩一区在线观看| 91国偷自产一区二区三区成为亚洲经典 | 国产宾馆实践打屁股91| 国产精品一区二区x88av| 久热成人在线视频| 精品中文av资源站在线观看| 麻豆精品在线看| 蜜臀国产一区二区三区在线播放| 五月天一区二区三区| 亚洲国产另类av| 亚洲成人激情av| 午夜精品成人在线| 日韩 欧美一区二区三区| 日韩av一区二区三区四区| 免费人成网站在线观看欧美高清| 免费看日韩精品| 国精产品一区一区三区mba视频| 久久国产精品免费| 国产精品一区二区久激情瑜伽| 成人综合婷婷国产精品久久免费| 成人的网站免费观看| 91福利在线观看| 欧美另类变人与禽xxxxx| 91精品国产91久久久久久最新毛片| 91麻豆精品国产自产在线| 精品国产123| 亚洲国产精品精华液ab| 亚洲私人黄色宅男| 日韩av电影免费观看高清完整版 | 性久久久久久久| 老色鬼精品视频在线观看播放| 国产九九视频一区二区三区| 成人免费电影视频| 在线视频欧美精品| 91精品国产一区二区人妖| 久久久久久久久蜜桃| 亚洲欧洲性图库| 午夜电影一区二区| 国产一区二区三区美女| 91精品中文字幕一区二区三区| 欧美一级精品大片| 国产精品美女一区二区在线观看| 亚洲一区二区三区国产| 久久99最新地址| 99精品视频在线免费观看| 欧美视频一区在线| 欧美精品一区二区三区蜜桃视频| 日韩伦理电影网| 美女一区二区在线观看| 99久久精品99国产精品| 欧美大片拔萝卜| 亚洲美腿欧美偷拍| 国产在线视频精品一区| 色综合天天天天做夜夜夜夜做| 欧美一区二区日韩| 亚洲久草在线视频| 狠狠v欧美v日韩v亚洲ⅴ| 欧美优质美女网站| 中文子幕无线码一区tr| 日本特黄久久久高潮| 97久久精品人人做人人爽50路 | 欧美大片在线观看一区| 亚洲激情成人在线| 国产成人三级在线观看| 3d成人动漫网站| 夜夜精品视频一区二区| 国产成人av影院| 欧美成人一区二区| 亚瑟在线精品视频| 色播五月激情综合网| 久久麻豆一区二区| 紧缚捆绑精品一区二区| 欧美乱妇一区二区三区不卡视频| 亚洲三级在线播放| 风间由美性色一区二区三区| 欧美成人精品二区三区99精品| 一区二区三区精品在线| 99热在这里有精品免费| 欧美国产日韩在线观看| 激情综合色综合久久| 欧美一区欧美二区| 亚洲大片精品永久免费| 欧洲一区二区三区在线| 国产精品理伦片| 成人国产一区二区三区精品| 国产三级欧美三级| 国产麻豆精品95视频| 久久夜色精品国产欧美乱极品| 麻豆精品国产传媒mv男同| 欧美一区二区在线不卡| 日韩成人免费电影| 欧美男女性生活在线直播观看| 樱花草国产18久久久久| 色呦呦一区二区三区| 亚洲精品乱码久久久久久黑人| av一区二区三区| 国产精品初高中害羞小美女文| 成人在线综合网| 中文字幕在线观看不卡| 成人av电影在线| 亚洲欧美日韩国产综合在线 | 欧美日韩精品一区二区天天拍小说| 亚洲激情男女视频| 欧美蜜桃一区二区三区| 日韩电影免费在线观看网站| 欧美一级艳片视频免费观看| 日本伊人色综合网| 精品对白一区国产伦| 国产精品影视在线| 国产精品区一区二区三区| 99久久99久久免费精品蜜臀| 亚洲美女屁股眼交3| 欧美日免费三级在线| 日韩高清不卡一区| 精品国产一区二区精华| 北岛玲一区二区三区四区 | 午夜一区二区三区在线观看| 欧美一区二区性放荡片| 国产精品综合久久| 亚洲男人的天堂在线aⅴ视频| 欧美午夜精品电影| 另类人妖一区二区av| 欧美激情艳妇裸体舞| 色又黄又爽网站www久久| 丝瓜av网站精品一区二区| 精品剧情在线观看| av在线一区二区三区| 五月天国产精品| 久久综合九色欧美综合狠狠 | 亚洲h在线观看| 久久丝袜美腿综合|