• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 906
  • Last Modified:

Delphi 6 ServerSocket ActiveConnections & Errors

I am trying to build Client-Server program, and I have 2 questions -

1) When testing ActiveConnections property on ClientDisconnect event, it is not updated. For example If I have 3 connections, and 1 of them is being disconnected now - the ActiveConnections still show 3. If I test this value outside this event (for example manually by a button) then it shows the right number. Why ? How should I see the right value at this event ?

2) What is error 10053 and why it appear from time to time /

Thanks & regards,
Ofer
0
oferlll
Asked:
oferlll
  • 3
1 Solution
 
Emmanuel PASQUIERFreelance Project ManagerCommented:
That is the way "closing" events usually works in Delphi, they are triggered before the objects are destroyed, so that you can act on it.
If you want to act on all remaining connections when one disconnect, you loop through all connections and just ignore the one corresponding to the event
0
 
Emmanuel PASQUIERFreelance Project ManagerCommented:
0
 
Emmanuel PASQUIERFreelance Project ManagerCommented:
Example that sends to all remaining hosts a message to inform that one of them disconnected.
Useful in network games.

procedure TMainForm.ServerSOCKClientDisconnect(Sender: TObject; Socket: TCustomWinSocket);
var i:integer;
begin
 With TServerSocket(Sender).Socket do 
  for i:=0 to ActiveConnections-1 do 
   if Connections[i]<>Socket Then
    begin
     Connections[i].SendText('Host disconnected from Server :'+Socket.LocalAddress);
    end;
end;

Open in new window

0
 
briangochnauerCommented:
It is not unusual to see errors; for many many reasons. You just have to handle them.
Both are caused when the remote computer ends the connection without first announcing the intension to do so.

WSAECONNABORTED
10053  Software caused connection abort.

    An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error.

WSAECONNRESET
10054  Connection reset by peer.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now