Solved

Delphi 6 ServerSocket ActiveConnections & Errors

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi cmd execution 6 60
Virtuailstring tree add node to another virtuailstring tree list 4 115
LAN or WAN ? 11 90
can't find the executable in Simulator 1 90
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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