473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Multiserver, multiclient, IP Address DCHP nightmare from hell

Hi,
This started off being a question along the lines of "how do i get the
local machine ip address?", which can be done using ....

String sIPAddress =
Dns.Resolve(System.Environment.MachineName).Addres sList[0].ToString

unfortunately, the [0] bit reminded me that a computer can have more
than one IP (technically, i hadn't forgotten, it had just become
obfuscated due to the hashing effect of alcohol).

So anyway(!), i have a server app (that can be installed on several
machines on a network) and a client app (several instances again), but
the servers could be sat on machines that have DHCP IP addresses.

What's the best way to get the clients to find the server if its IP has
changed?

I was considering using some form of broadcast from the server that
would perpetuate until it 'knew' all the clients had found its new
location? And this is where the multiple IP addresses come in beacuse i
also need to know if the AddressList always enumerates the IP's in the
same order (what if a network adapter had broken, etc), because my
server needs to know which IP it should be broadcasting to the clients.

Afterthought!: Is there a way to find out the MAC address of an IP
because i could use that?

Thankyou in advance you clever people you!
James Randle.

Jul 30 '06 #1
8 1962
I've found some code to get the MAC Address, but it seems to be
returning *a lot* of addresses. Does anyone know why this is happening?

ManagementObjectSearcher wmiObj= new ManagementObjectSearcher("select
AdapterType, MACAddress from Win32_NetworkAdapter");

foreach (ManagementObject item in wmiObj.Get())
{
MessageBox.Show((string)item["MACAddress"] + " | " +
(string)item["AdapterType"]);
}

I have one wireless and one wired adapter, but this code returns 17
rows! Some are actually blank, which is akin to my current facial
expression.

Thanks,
James Randle.

pigeonrandle wrote:
Hi,
This started off being a question along the lines of "how do i get the
local machine ip address?", which can be done using ....

String sIPAddress =
Dns.Resolve(System.Environment.MachineName).Addres sList[0].ToString

unfortunately, the [0] bit reminded me that a computer can have more
than one IP (technically, i hadn't forgotten, it had just become
obfuscated due to the hashing effect of alcohol).

So anyway(!), i have a server app (that can be installed on several
machines on a network) and a client app (several instances again), but
the servers could be sat on machines that have DHCP IP addresses.

What's the best way to get the clients to find the server if its IP has
changed?

I was considering using some form of broadcast from the server that
would perpetuate until it 'knew' all the clients had found its new
location? And this is where the multiple IP addresses come in beacuse i
also need to know if the AddressList always enumerates the IP's in the
same order (what if a network adapter had broken, etc), because my
server needs to know which IP it should be broadcasting to the clients.

Afterthought!: Is there a way to find out the MAC address of an IP
because i could use that?

Thankyou in advance you clever people you!
James Randle.
Jul 30 '06 #2
A relatively simple way would be to have the server, when it is started,
update a row on a database with it's current IP address.
Each client, when it starts, can either query the database, or hit a
webservice which would return the correct IP address to look for.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"pigeonrandle" wrote:
Hi,
This started off being a question along the lines of "how do i get the
local machine ip address?", which can be done using ....

String sIPAddress =
Dns.Resolve(System.Environment.MachineName).Addres sList[0].ToString

unfortunately, the [0] bit reminded me that a computer can have more
than one IP (technically, i hadn't forgotten, it had just become
obfuscated due to the hashing effect of alcohol).

So anyway(!), i have a server app (that can be installed on several
machines on a network) and a client app (several instances again), but
the servers could be sat on machines that have DHCP IP addresses.

What's the best way to get the clients to find the server if its IP has
changed?

I was considering using some form of broadcast from the server that
would perpetuate until it 'knew' all the clients had found its new
location? And this is where the multiple IP addresses come in beacuse i
also need to know if the AddressList always enumerates the IP's in the
same order (what if a network adapter had broken, etc), because my
server needs to know which IP it should be broadcasting to the clients.

Afterthought!: Is there a way to find out the MAC address of an IP
because i could use that?

Thankyou in advance you clever people you!
James Randle.

Jul 30 '06 #3
Peter,
Thanks for your suggestion, i like it! Alas though, i want to avoid
using anything outside of my control (like a database that someone
could muck up, or even better delete because they dont know what it is
there for ..! once bitten, etc).
I had considered a similar solution using a file on a shared folder,
but i reckon the broadcast solution is 'optimal' :o).

As long as i can find out what NIC was selected (by the IP they choose)
when the server is set up, i can use the (stored) MAC to check if the
IP has changed after the server has restarted. I can then broadcast the
change until all the clients 'know'.

In a perfect world i would definitely go for the database option, but
as we both know this world is far from perfect!

Thanks again,
James.

Peter Bromberg [ C# MVP ] wrote:
A relatively simple way would be to have the server, when it is started,
update a row on a database with it's current IP address.
Each client, when it starts, can either query the database, or hit a
webservice which would return the correct IP address to look for.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"pigeonrandle" wrote:
Hi,
This started off being a question along the lines of "how do i get the
local machine ip address?", which can be done using ....

String sIPAddress =
Dns.Resolve(System.Environment.MachineName).Addres sList[0].ToString

unfortunately, the [0] bit reminded me that a computer can have more
than one IP (technically, i hadn't forgotten, it had just become
obfuscated due to the hashing effect of alcohol).

So anyway(!), i have a server app (that can be installed on several
machines on a network) and a client app (several instances again), but
the servers could be sat on machines that have DHCP IP addresses.

What's the best way to get the clients to find the server if its IP has
changed?

I was considering using some form of broadcast from the server that
would perpetuate until it 'knew' all the clients had found its new
location? And this is where the multiple IP addresses come in beacuse i
also need to know if the AddressList always enumerates the IP's in the
same order (what if a network adapter had broken, etc), because my
server needs to know which IP it should be broadcasting to the clients.

Afterthought!: Is there a way to find out the MAC address of an IP
because i could use that?

Thankyou in advance you clever people you!
James Randle.
Jul 30 '06 #4
WTH
What's the best way to get the clients to find the server if its IP
has changed?
Use a name which will be resolved (by you) via DNS instead of the IP
Address. We have this situation with our product in the field. Customers
who use DHCP without reservations on the IP Addresses and customers who
change names but not IP addresses. Our system lets them specify either the
IP Address or the name of the machine. We occasionally get customers who
like to change both, but let's not talk about them ;)... This should also
resolve your multi-card server issues as only one of them will be bound by
DNS to a particular name.

WTH

--
"I was really surprised when the FA knocked on my doorbell." - Michael
Owen
Jul 30 '06 #5
WTH
WTH <sp*******@Ih8it.comloquated like no one had ever loquated before
with:
>What's the best way to get the clients to find the server if its IP
has changed?

Use a name which will be resolved (by you) via DNS instead of the IP
Address. We have this situation with our product in the field. Customers
who use DHCP without reservations on the IP Addresses and
customers who change names but not IP addresses. Our system lets
them specify either the IP Address or the name of the machine. We
occasionally get customers who like to change both, but let's not
talk about them ;)... This should also resolve your multi-card
server issues as only one of them will be bound by DNS to a
particular name.
WTH
This must have occurred to you already, did I miss something in your problem
description?

Are you aware that you can't use two network interfaces from the same
machine on the same network? Just checking. By this I mean that if you
have a machine with four cards, only one of them will interface to a
particular network.

WTH

--
"I was really surprised when the FA knocked on my doorbell." - Michael
Owen
Jul 30 '06 #6
WTH,
Thankyou for replying.

I was, infact, unaware that you couldn't have two network cards
connecting to the same network. That's the best news i heard all day!

Thankyou,
James Randle.
WTH wrote:
WTH <sp*******@Ih8it.comloquated like no one had ever loquated before
with:
What's the best way to get the clients to find the server if its IP
has changed?
Use a name which will be resolved (by you) via DNS instead of the IP
Address. We have this situation with our product in the field. Customers
who use DHCP without reservations on the IP Addresses and
customers who change names but not IP addresses. Our system lets
them specify either the IP Address or the name of the machine. We
occasionally get customers who like to change both, but let's not
talk about them ;)... This should also resolve your multi-card
server issues as only one of them will be bound by DNS to a
particular name.
WTH

This must have occurred to you already, did I miss something in your problem
description?

Are you aware that you can't use two network interfaces from the same
machine on the same network? Just checking. By this I mean that if you
have a machine with four cards, only one of them will interface to a
particular network.

WTH

--
"I was really surprised when the FA knocked on my doorbell." - Michael
Owen
Jul 30 '06 #7
WTH
pigeonrandle <pi**********@hotmail.comloquated like no one had ever
loquated before with:
WTH,
Thankyou for replying.

I was, infact, unaware that you couldn't have two network cards
connecting to the same network. That's the best news i heard all day!

Thankyou,
James Randle.
Lol, no problem. Now, I don't know how true this is for other operating
systems, but Windows won't let you put two NICs on the same network, but
Linux and other *nix systems will let you do so (BSD flavors for example.)

I'm 99.9% sure that you can't on any of the Windows OSes though.

WTH:)

--
"A player who needs inspiring is not a player, but with [the Kop]
behind you, you are doubly inspired." - Bill Shankly
Jul 31 '06 #8
WTH,
Thanks again. I'm hoping i will only have to have the server running on
windows machines, but know that at some point i will have to 'learn
linux' to expand my market. Happy happy joy joy :oP

Cheers,
James.
WTH wrote:
pigeonrandle <pi**********@hotmail.comloquated like no one had ever
loquated before with:
WTH,
Thankyou for replying.

I was, infact, unaware that you couldn't have two network cards
connecting to the same network. That's the best news i heard all day!

Thankyou,
James Randle.

Lol, no problem. Now, I don't know how true this is for other operating
systems, but Windows won't let you put two NICs on the same network, but
Linux and other *nix systems will let you do so (BSD flavors for example.)

I'm 99.9% sure that you can't on any of the Windows OSes though.

WTH:)

--
"A player who needs inspiring is not a player, but with [the Kop]
behind you, you are doubly inspired." - Bill Shankly
Jul 31 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: VooDoo | last post by:
Hi, Is it possible to have the MAC adress of the client that connect to a php page? I have the IP adress, if it's not possible to have directly is it possible to query the DCHP server and have...
9
by: Don | last post by:
How can I get the client's IP address from within an HTML page using embedded JS? Thanks for your help, Don ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----...
21
by: Alexander N. Spitzer | last post by:
If I have a machine with 3 virtual IP addresses (192.168.1.), how can I start 3 instances of the same RMI application (each started with different properties/configs), each listening on the port...
7
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of...
1
by: René Dohmen | last post by:
I want to set up Multiserver Administration. The problem I encounter is a firewall between the master server and some target servers. What ports need to be set open to make this possible ?
26
by: Adam Warner | last post by:
Hello all, I'm very new to C but I have a number of years of Common Lisp programming experience. I'm trying to figure out ways of translating higher order concepts such as closures into C. The...
1
by: GreatB | last post by:
Bill Gates died in a car accident. He found himself in Purgatory being sized up by God . .. "Well, Bill, I'm really confused on this call. I'm not sure whether to send you to Heaven or Hell....
24
by: Daniel Crespo | last post by:
Hi, I tried: import ctypes import socket import struct def get_macaddress(host): """ Returns the MAC address of a network host, requires >= WIN2K. """
3
by: 2401 members, members can post | last post by:
Dear Madams and Sirs, Ever had to split a website + SQL Tables ? Have a UNIX pc-linux-gnu on i686 + FEDORA 1) We have to split a sub-domain for the main domain name. 2) We have to build a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.