Solved

Checking if server is ready for connection (Clientsocket and server socket)

Posted on 2004-04-27
5
602 Views
Last Modified: 2010-04-05
I am using clientsocket and serversocket in aclient server application , I want the client to check if the server is ready and liesting before trying to connect to it . how to do that ??
0
Comment
Question by:Prof_MAM
  • 3
5 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10932630

 if ServerSocket.Active = True

TServerSocket listens for requests for TCP/IP connections from other machines, and establishes connections when requests are received, once the component is active...

 Shane
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 20 total points
ID: 10932659
oops sorry, i missed the first part.... "I want the client to check"

There is no way to determine if the remote host (Server) is active from the Client.

 You just keep trying to connect until successful or a condition has been made... (example: time)


Shane

1
 

Author Comment

by:Prof_MAM
ID: 10940247
then tell me how to keep trying until Connection happens
0
 
LVL 4

Expert Comment

by:ceoworks
ID: 10940977
Hi,

If your client and server programs is working in the same network, you may wants to choose to multicasting. With it, when your server connected, it can send multicast message to the network and when your client(which is listening multicast packages..) get this message, you can know that your server is available for to connect. Another advantage of this model is, your clients doesn't needs to know about your server ip then. It can find it easily with sending a multicast package to the network and wait for server to reply and send it's IP.

If you have Indy components, you can use Indy's TIdIPMCastServer/Client components for to do that. If you don't have you can download from http://www.indyproject.org.

Kind Regards,

Oktay
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10941177


in your OnError event of the CLientSocket would be the best place to do it i think

procedure TForm1.Button3Click(Sender: TObject);
begin
  ErrorCount := 0;
  ClientSocket.Active := true;
end;


procedure TForm1.ClientSocketError(Sender: TObject;
  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
  var ErrorCode: Integer);
begin
  inc(ErrorCount);
  Memo1.Lines.Add (IntToStr(ErrorCount) + ' - ErrorCode: ' + IntToSTr(ErrorCode));
  { ignore error }
  ErrorCode := 0;
 if Error Count < 100 do
  ClientSocket.active := TRUE;
end;

Shane
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

815 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now