LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-04-2006, 03:58 PM   #1
Panagiotis_IOA
Member
 
Registered: Jan 2006
Location: Hellas, Europe
Distribution: Slackware 12
Posts: 238

Rep: Reputation: 32
Getting LocalHost on Java


Well, I just wrote a program for promting the localhost ip address. The problem is that takes as ip the l0 and not the eth0. As I know l0 is for Linux "talking" to its self.
Is there a way for defining to which adapter to check?

Thanks in advance.
 
Old 05-04-2006, 07:57 PM   #2
destuxor
Member
 
Registered: Oct 2005
Posts: 51

Rep: Reputation: 16
I think this example will show you what you need: http://www.rgagnon.com/javadetails/java-0390.html.

In Linux, the external IP address will usually be on the network interface "eth0". Localhost is always 127.0.0.1 (technically, anything with an IP address starting with 127 is a loopback adapter, but so many programs have "127.0.0.1" hardcoded into them that operating system programmers make sure that the "lo" is always 127.0.0.1). The loopback adapter is often used for IPC (inter-process communication).

If you'll look at the documentation, you'll see that you can "getByName".
 
Old 05-04-2006, 08:53 PM   #3
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
try playing with inetadress, i think there is a method to check if the address is the loopback address.
 
Old 05-05-2006, 05:37 AM   #4
Panagiotis_IOA
Member
 
Registered: Jan 2006
Location: Hellas, Europe
Distribution: Slackware 12
Posts: 238

Original Poster
Rep: Reputation: 32
Thanks destuxtor for the first link, that sovled the problem. I used getByName for getting the IPs of other hosts.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change localhost name in username@localhost n175uj Linux - Newbie 4 07-01-2005 08:25 PM
apache http://localhost/mysite ---> http://localhost/mysite/index.php how? ilnli Linux - General 8 06-04-2005 03:23 PM
Message from syslogd@localhost localhost kernel: Disabling IRQ #21 ylts Linux - Hardware 0 02-26-2005 08:01 AM
dns requests from localhost to localhost keex Linux - Networking 2 11-13-2003 01:47 PM
Telnet localhost and telnet not from localhost for IMAP services seb77 Linux - Networking 1 10-15-2003 01:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration