Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delphi 6 ServerSocket ActiveConnections & Errors

Posted on 2010-11-23
4
Medium Priority
?
886 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

604 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