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 | |
---|
1 | unit ftpmain;
|
---|
2 |
|
---|
3 | {$IFDEF FPC}
|
---|
4 | {$mode delphi}
|
---|
5 | {$endif}
|
---|
6 |
|
---|
7 | interface
|
---|
8 |
|
---|
9 | uses
|
---|
10 | {$IFDEF LINUX}
|
---|
11 | Libc,
|
---|
12 | {$ELSE}
|
---|
13 | Windows,
|
---|
14 | {$ENDIF}
|
---|
15 | Classes, SysUtils, ftpthrd, blcksock, synsock;
|
---|
16 |
|
---|
17 | type
|
---|
18 | TServiceThread = class(TThread)
|
---|
19 | private
|
---|
20 | { Private declarations }
|
---|
21 | protected
|
---|
22 | procedure Execute; override;
|
---|
23 | public
|
---|
24 | constructor Create;
|
---|
25 | end;
|
---|
26 |
|
---|
27 |
|
---|
28 | implementation
|
---|
29 |
|
---|
30 | {==============================================================================}
|
---|
31 | { TServiceThread }
|
---|
32 |
|
---|
33 | constructor TServiceThread.create;
|
---|
34 | begin
|
---|
35 | inherited create(false);
|
---|
36 | FreeOnTerminate := false;
|
---|
37 | // Priority := tpNormal;
|
---|
38 | end;
|
---|
39 |
|
---|
40 | procedure TServiceThread.Execute;
|
---|
41 | var
|
---|
42 | ClientSock: TSocket;
|
---|
43 | sock: TTCPBlockSocket;
|
---|
44 | begin
|
---|
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;
|
---|
64 | end;
|
---|
65 |
|
---|
66 | {==============================================================================}
|
---|
67 | end.
|
---|
Note:
See
TracBrowser
for help on using the repository browser.