Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bind socket to a network interface

Status
Not open for further replies.

klingoni

Technical User
Apr 30, 2002
5
CH
hello together

i really need some help: i have an application that needs two sockets using two different interfaces with the same ip address. i wrapped the two sockets into a "supersocket" which should send out any packet on both interfaces, but this doesn't work. these are the interfaces:

- eth1 (192.168.220.4)
- pan0 (192.168.220.4)

i have to do this because one socket is used for wireless (eth1) and the other is bluetooth (pan0) and a broadcast must reach all devices (wireless and bluetooth). unfortunately, java doesn't let me bind a socket to a specific network interface but only to an IP address. like this, it simply binds the socket to the first interface with the given IP address. like this, if a device has wirelss and bluetooth network interfaces active with the identical IP address it will only send it over eth1 and no bluetooth device around will hear the broadcast... i need to bind socket1 to eth1 and socket2 to pan0, but how? does anyone know, how i can bind a socket to an interface / MAC address or any other solution for this??

help is greatly appreciated because i'm quite stuck

sebastian
 
thanks for your replies. using two different IP addresses for the two different interfaces would force java to use bluetooth and wireless of course, but for the application we're building on top of this adhoc network, each device should only have one IP address. a user should not have to configure a machine with different IPs for the several interfaces, we want to keep things as "simple" as possible for the final user. does anyone know of a tool to create virtual interfaces under linux, i.e. to put "eth1" and "pan0" into "vif0" for example. then we could multiplex a java send onto the interfaces operating with different technologies?
 
That doesn't sound plausible to me.
One IP for two devices is at least as complicated, as two ips.

If a request is made to a certain IP, which should react?
Both?

If something doesn't work, where shall the user search for an error?
One IP per device would make this much more easy.
Making things simple - I agree.
But not too simple!

seeking a job as java-programmer in Berlin:
 
You need to use J2ME - look at the links I gave you.
J2SE is just not deisgned for talking to MAC addresses and the like via single IPs ....
Its like trying to fry an egg when you only have a grill ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top