Solved

Delphi 6 ServerSocket ActiveConnections & Errors

Posted on 2010-11-23
4
871 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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