Autor Beitrag
NeWsOfTzzz
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: Sa 30.10.04 04:38 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.ServerSocket1ClientDisconnect(Sender: TObject;
  Socket: TCustomWinSocket);
var x:integer;
begin
dec(game.actives);
if TConnectionData(socket.data^).Accountindex>0 then begin
  log.items.add(Socket.RemoteAddress+':'+IntToStr(Socket.RemotePort)+' has logged out.'+IntToStr(TConnectionData(socket.data^).AccountIndex));
  dec(Game.loggedcount);
  Accounts[TConnectionData(socket.data^).AccountIndex].logged:=false;
  TConnectionData(socket.data^).Accountindex:=0;
end;
for x:=tconnectiondata(socket.data^).index+1 to game.actives do begin
ServerSocket1.Socket.Connections[x].data:=addr(connectiondata[x-1]);
connectiondata[x-1].Accountindex:=connectiondata[x].Accountindex;
connectiondata[x-1].Playerindex:=connectiondata[x].Playerindex;
end;
log.items.add(Socket.remoteaddress+':'+inttostr(Socket.remoteport)+' disconnected.');
end;


Wenn ich sagen wir mal 30 Clients verbinde und ich die nach und nach von Hand disconnecte.. treten gar keine Probleme auf. Wenn ich jetzt aber 10-30 clients gleichzeitig beende kriege ich auf einmal total verdrehte ergebnisse, als ob onclientdisconnect gleichzeitig aufgerufen würde und der eine schiebt in connectiondata was nach links während der andere noch am lesen ist.. und ja serversocket1.servertype=stnonblocking.. also ich versteh das net und als ich testweise am anfang von onclientdisconnect serversocket1.socket.lock und am ende serversocket1.socket.unlock ausgeführt habe, hat das auch nix geändert... Also woran liegt das :(

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
herzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 168

WINXP pro, SUSE Linux 9.0
D7 Pers.
BeitragVerfasst: So 31.10.04 09:03 
Hi,

hast du jetzt serversocket1.lock oder socket.lock versucht. Habs zwar nicht getestet aber mit einer von den beiden sollte es doch funktionierne!
NeWsOfTzzz Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 233


D4 Prof
BeitragVerfasst: So 31.10.04 09:41 
ich hab ServerSocket1.Socket.lock benutzt..