Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Long ip's

Posted on 1999-07-28
8
Medium Priority
?
202 Views
Last Modified: 2010-04-04
Hi there,

Does anyone have a peice of source code for me that can convert a 32-bit long ip (eg 3498393929112 ???) to an normal ip adress like 192.168.0.1 en visa versa.

Thanks
0
Comment
Question by:aluiken
[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
  • 4
  • 3
8 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 800 total points
ID: 1391551
Quite easy:

var i1 : integer;
    s1 : string;
begin
  i1:=inet_addr('192.168.32.100');
  s1:=inet_ntoa(in_addr(i1));
  ShowMessage(s1);
end;

Regards, Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1391552
P.S: Add "winSock" to your "uses" clause.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1391553
sh*t - u've been faster again...

;-)
SlowDeath.
0
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.

 
LVL 1

Author Comment

by:aluiken
ID: 1391554
Okiz, but the other way around ?

Or is the func to convert a '192.168.0.1' like to an long the inet_addr func ?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1391555
My example does both. "inet_addr" converts a string into an integer. "inet_ntoa" goes the other way round (integer -> string). Easy, isn't it!?   :-)

Sorry to SlowDeath...   :-))

P.S: If you want to convert a string variable into an integer, do this:

intVar:=inet_addr(pchar(strVar));
0
 
LVL 1

Author Comment

by:aluiken
ID: 1391556
Okiz thx !
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1391557
If it works, please don't forget to accept my answer...   :-)
0
 
LVL 1

Author Comment

by:aluiken
ID: 1391558
Sorry =) got the wrong button.

(Did not check it if it works tough)

Greets
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

705 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