source: trunk/Packages/synapse/source/demo/ftpserv/ftpmain.pas

Last change on this file was 2, checked in by chronos, 12 years ago
  • Přidáno: Základní kostra projektu.
  • Přidáno: Knihovna synapse.
File size: 1.2 KB
Line 
1unit ftpmain;
2
3{$IFDEF FPC}
4 {$mode delphi}
5{$endif}
6
7interface
8
9uses
10{$IFDEF LINUX}
11 Libc,
12{$ELSE}
13 Windows,
14{$ENDIF}
15 Classes, SysUtils, ftpthrd, blcksock, synsock;
16
17type
18 TServiceThread = class(TThread)
19 private
20 { Private declarations }
21 protected
22 procedure Execute; override;
23 public
24 constructor Create;
25 end;
26
27
28implementation
29
30{==============================================================================}
31{ TServiceThread }
32
33constructor TServiceThread.create;
34begin
35 inherited create(false);
36 FreeOnTerminate := false;
37// Priority := tpNormal;
38end;
39
40procedure TServiceThread.Execute;
41var
42 ClientSock: TSocket;
43 sock: TTCPBlockSocket;
44begin
45 sock := TTCPBlockSocket.Create;
46 try
47 sock.bind('0.0.0.0','21');
48 sock.setLinger(true, 10000);
49 sock.listen;
50 if sock.LastError <> 0 then
51 exit;
52 while not terminated do
53 begin
54 if sock.canread(1000) then
55 begin
56 ClientSock := sock.accept;
57 if sock. lastError = 0 then
58 TFtpServerThread.create(ClientSock);
59 end;
60 end;
61 finally
62 sock.Free;
63 end;
64end;
65
66{==============================================================================}
67end.
Note: See TracBrowser for help on using the repository browser.