Solved

Delphi 6 ServerSocket ActiveConnections & Errors

Posted on 2010-11-23
4
868 Views
Last Modified: 2012-05-10
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
Comment
Question by:oferlll
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 25

Expert Comment

by:epasquier
ID: 34196878
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
 
LVL 25

Expert Comment

by:epasquier
ID: 34196904
0
 
LVL 25

Accepted Solution

by:
epasquier earned 500 total points
ID: 34196982
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
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34198824
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question