INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Networking

How do I check if an IP Address exists or not? by djjd47130
Posted: 2 Jan 11 (Edited 27 May 11)

This function uses the Indy Clients, and checks if a given IP Address is valid or not by Pinging that IP. If it receives anything back, it returns true, or else if it does not get a reply, it returns false.

CODE

// for automatic syntax highlighting see FAQ102-6487: How to include syntax highlighting in code examples.

unit IPVerify;

interface

uses
  IdBaseComponent, IdComponent, IdRawBase, IdRawClient, IdIcmpClient,
  Windows, Messages, Classes, SysUtils;

function IPExists(IPAddr: String): Bool;

implementation

function IPExists(IPAddr: String): Bool;
var
  I: TIdIcmpClient;
  Rec: Integer;
begin
  Result:= False;
  I:= TIdIcmpClient.Create(nil);
  try
    I.Host:= IPAddr;
    I.Ping();
    Sleep(2000);
    Rec:= I.ReplyStatus.BytesReceived;
    if Rec > 0 then Result:= True else Result:= False;
  finally
    I.Free;
  end;
end;

end.
 

Back to Embarcadero: Delphi FAQ Index
Back to Embarcadero: Delphi Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close