Solved

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

Posted on 2004-04-27
5
592 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
Comment Utility

 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
Comment Utility
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
Comment Utility
then tell me how to keep trying until Connection happens
0
 
LVL 4

Expert Comment

by:ceoworks
Comment Utility
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
Comment Utility


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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

13 Experts available now in Live!

Get 1:1 Help Now