mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Flinders <P.Flinders@ftel.co.uk>
To: Rob Landley <telomerase@yahoo.com>
Cc: Philippe Troin <phil@fifi.org>,
	Jeff Garzik <jgarzik@mandrakesoft.com>,
	linux-kernel@vger.kernel.org
Subject: Re: 255.255.255.255 won't broadcast to multiple NICs
Date: 03 Nov 2000 18:11:15 +0000	[thread overview]
Message-ID: <thvn1fhsz7g.fsf@solar-flare.ftel.co.uk> (raw)
In-Reply-To: <20001103173316.17356.qmail@web5201.mail.yahoo.com>
In-Reply-To: Rob Landley's message of "Fri, 3 Nov 2000 09:33:16 -0800 (PST)"


Rob Landley <telomerase@yahoo.com> writes:
> 3) Java sucks in many ways.  Today's way is that it
> never occurred to Sun that a machine might have more
> than one IP address assigned to it, so
> InetAddress.getLocalHost() returns exactly one
> address.  Unfortunately, just about EVERY machine has
> two interfaces defined, the other one being loopback
> on 127.0.0.1, and natrually the loopback is the one
> that getLocalHost() returns.  (Since it's the one that
> we pretty much already know the address of anyway, and
> querying it is therefore useless, that's the one it
> queries.  Thank you Sun.)  There is no way to query
> the current machine's interfaces without resorting to
> native code.

I faced this problem a while ago - in the end I cheated and
put this bit of code in a shell script used to start the
application

    NET_ADDRESSES=`/sbin/ifconfig   |                         \
                   awk '/^[^   ].*HWaddr/ { HWaddr=$5; next;}
                        /^[^        ]/ { HWaddr=0; }
                        /^[         ].*addr:/ { if (HWaddr != 0) { printf("-Dethaddr.%s=%s -Dnetmask.%s=%s ",substr($2,6),HWaddr,substr($2,6),substr($4,6)); } } END {print;}'`

including ${NET_ADDRESSES} in the java command line sets
up a set of defines, one per interface. For example

-Dethaddr.172.16.1.1=00:00:0A:BC:CD:78 -Dnetmask.172.16.1.1=255.255.0.0

which you can use via System.getProperty() and System.getProperties()

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

  reply	other threads:[~2000-11-03 18:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-03 17:33 Rob Landley
2000-11-03 18:11 ` Paul Flinders [this message]
2000-11-03 20:19 ` Philippe Troin
  -- strict thread matches above, loose matches on Subject: below --
2000-11-04  3:15 Rob Landley
2000-11-03 19:46 Rob Landley
2000-11-03  4:17 Rob Landley
2000-11-03  1:22 Rob Landley
2000-11-03  2:14 ` Philippe Troin
2000-11-02 23:55 Rob Landley
2000-11-03  0:29 ` Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=thvn1fhsz7g.fsf@solar-flare.ftel.co.uk \
    --to=p.flinders@ftel.co.uk \
    --cc=jgarzik@mandrakesoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phil@fifi.org \
    --cc=telomerase@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®