Solved

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

Posted on 2004-04-27
5
640 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
[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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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