C
cb1997
Unregistered / Unconfirmed
GUEST, unregistred user!
部分程序如下
程序主要作用是多线程传输文件,客户端没问题,壳户端用多线程连接,服务器端接收数据时有点问题(服务器端可进行多个连接)
我自己找了找觉得好象就是带//???????????????????????? 的那两句好象有点冲突,我该如何修改啊
//服务器端
。。。。。
type
PClient = ^TClient;
TClient = record
DNS : String[20];
Connected,
LastAction : TDateTime;
Thread : Pointer;
end;
TDataState = (dstNone, dstReceiving);
TThreadData = class
private
FState: TDataState;
FFileSize: Integer;
FStream: TFileStream;
procedure SetState(const Value: TDataState);
procedure SetFileSize(const Value: Integer);
procedure SetStream(const Value: TFileStream);
public
constructor Create;
destructor Destroy;
override;
property State : TDataState read FState write SetState;
property FileSize : Integer read FFileSize write SetFileSize;
property Stream : TFileStream read FStream write SetStream;
end;
。。。。。。
procedure TfrmMain.IdTCPSConnect(AThread: TIdPeerThread);
var
NewClient: PClient;
begin
GetMem(NewClient,sizeOf(TClient));
NewClient.DNS := AThread.Connection.LocalName;
NewClient.Connected := Now;
NewClient.LastAction := NewClient.Connected;
NewClient.Thread := AThread;
[red] //???????????????????????? AThread.Data := TObject(NewClient);[/red]
Mehis.Lines.Add(TimeTOStr(time) + NewClient.DNS + '成功连入本机!');
try
CltThrdList.LockList.Add(NewClient);
finally
CltThrdList.UnlockList;
end;
end;
procedure TfrmMain.IdTCPSExecute(AThread: TIdPeerThread);
begin
[red]//???????????????????????? with AThread.Data as TThreadDatado
[/red]
begin
if State = DstNone then
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
。。。。
end;
end
else
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
。。。。。。。
end;
end;
end;
end;
程序主要作用是多线程传输文件,客户端没问题,壳户端用多线程连接,服务器端接收数据时有点问题(服务器端可进行多个连接)
我自己找了找觉得好象就是带//???????????????????????? 的那两句好象有点冲突,我该如何修改啊
//服务器端
。。。。。
type
PClient = ^TClient;
TClient = record
DNS : String[20];
Connected,
LastAction : TDateTime;
Thread : Pointer;
end;
TDataState = (dstNone, dstReceiving);
TThreadData = class
private
FState: TDataState;
FFileSize: Integer;
FStream: TFileStream;
procedure SetState(const Value: TDataState);
procedure SetFileSize(const Value: Integer);
procedure SetStream(const Value: TFileStream);
public
constructor Create;
destructor Destroy;
override;
property State : TDataState read FState write SetState;
property FileSize : Integer read FFileSize write SetFileSize;
property Stream : TFileStream read FStream write SetStream;
end;
。。。。。。
procedure TfrmMain.IdTCPSConnect(AThread: TIdPeerThread);
var
NewClient: PClient;
begin
GetMem(NewClient,sizeOf(TClient));
NewClient.DNS := AThread.Connection.LocalName;
NewClient.Connected := Now;
NewClient.LastAction := NewClient.Connected;
NewClient.Thread := AThread;
[red] //???????????????????????? AThread.Data := TObject(NewClient);[/red]
Mehis.Lines.Add(TimeTOStr(time) + NewClient.DNS + '成功连入本机!');
try
CltThrdList.LockList.Add(NewClient);
finally
CltThrdList.UnlockList;
end;
end;
procedure TfrmMain.IdTCPSExecute(AThread: TIdPeerThread);
begin
[red]//???????????????????????? with AThread.Data as TThreadDatado
[/red]
begin
if State = DstNone then
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
。。。。
end;
end
else
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
。。。。。。。
end;
end;
end;
end;