서버- 인디
클라이언트 - 소켓
1:1 일때문 아무문제 없이 잘 됩니다.
그런데 클라이언트가 2개 이상만되면 소켓 10053 에러가 발생합니다.
서버소켓으로 할때는 괜찮았던거 같은데;; 꼭 인디로 바꿔야 되서..
소스 보고 짐작가는 부분적 지적해주세여;;
procedure TfServerSocket.ServerConnect(AThread: TIdPeerThread);
var
NewClient: PClient;
begin
AThread.FreeOnTerminate := true;
AThread.Data := Clients;
try
Clients.LockList.Add(Clients);
finally
Clients.UnlockList;
end;
Memo1.Lines.Add(TimeToStr(Time)+' Connection');
end;
procedure TfServerSocket.ServerDisconnect(AThread: TIdPeerThread);
var
ActClient: PClient;
begin
Memo1.Lines.Add (TimeToStr(Time)+' Disconnect');
try
Clients.LockList.Remove(Clients);
finally
Clients.UnlockList;
end;
AThread.Data := nil;
end;
procedure TfServerSocket.ServerExecute(AThread: TIdPeerThread);
var
ActClient, RecClient: PClient;
NewCommBlock: TWData;
RecThread: TIdPeerThread;
i: Integer;
Temp : String;
ErrCode:HRESULT;
CloseDate:string;
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
ActClient := PClient(AThread.Data);
ActClient.LastAction := Now; // update the time of last action
if Not Assigned(TxData) then TxData:=TWData.Create(nil);
Txdata.DataStr := AThread.Connection.CurrentReadBuffer;
Set_log(Format('[%d]%s',[Handle,'-->> '+TxData.DataStr]));
if Memo1.Lines.Count > 10000 then Memo1.Clear;
Memo1.Lines.Add(Format('[%d]R[%s]',[Handle,TxData.DataStr]));
DataModule1.SocketHWND:=Handle;
DataModule1.ErrorCode:=S_MD_OK;
Memo1.Lines.Add(Format('[%d]A[%s]',[Handle,TxData.DataStr]));
AThread.Connection.Write(TxData.DataStr);
end;
end;