 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Mike Warren Guest
|
Posted: Thu Dec 30, 2004 10:23 pm Post subject: Finding a server on LAN |
|
|
Hi,
I intend to use TidTCPClient and TidTCPServer for communication
between a server and several clients.
Is there a way for my clients to find my server on a LAN when the
clients don't know the IP Address or computer name where the
server is? This could be used on a 10.x.x.x network so there are
too many addresses to check each one.
-Mike
|
|
| Back to top |
|
 |
Eugene Mayevski Guest
|
Posted: Thu Dec 30, 2004 10:35 pm Post subject: Re: Finding a server on LAN |
|
|
Hello!
You wrote on Fri, 31 Dec 2004 08:23:53 +1000:
MW> Is there a way for my clients to find my server on a LAN when the
MW> clients don't know the IP Address or computer name where the
MW> server is? This could be used on a 10.x.x.x network so there are
MW> too many addresses to check each one.
Use UDP broadcast -- the client should send a packet which asks the server
to report it's existence to the client. Also there can be some non-TCP
methods like creating a predefined name (if the server is planned to be the
only one in the LAN) or use active directory or something similat.
With best regards,
Eugene Mayevski
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Dec 30, 2004 11:09 pm Post subject: Re: Finding a server on LAN |
|
|
"Eugene Mayevski" <mayevski (AT) eldos (DOT) org> wrote
| Quote: | Use UDP broadcast -- the client should send a packet which
asks the server to report it's existence to the client.
|
The thing to watch out for is that UDP does not usually pass through
routers, so if the network contains multiple subnets, the client on one
subnet may not be able to find a server on another subnet even though TCP
will be able to connect them fine.
Gambit
|
|
| Back to top |
|
 |
Mike Warren Guest
|
Posted: Thu Dec 30, 2004 11:10 pm Post subject: Re: Finding a server on LAN |
|
|
Hi Eugene,
| Quote: | Is there a way for my clients to find my server on a LAN when the
clients don't know the IP Address or computer name where the
server is?
Use UDP broadcast -- the client should send a packet which asks the
server to report it's existence to the client.
|
Thanks for the reply. I won't know anything about the network it is going
to be on.
Do you know of an example or more information to start me on
learning how to use UDP broadcast.
Regards
-Mike
|
|
| Back to top |
|
 |
Mike Warren Guest
|
Posted: Thu Dec 30, 2004 11:54 pm Post subject: Re: Finding a server on LAN |
|
|
Hi,
| Quote: | Use UDP broadcast -- the client should send a packet which
asks the server to report it's existence to the client.
The thing to watch out for is that UDP does not usually pass through
routers, so if the network contains multiple subnets, the client on
one subnet may not be able to find a server on another subnet even
though TCP will be able to connect them fine.
|
The clients are setup by DHCP and have no user access so I can't
do anything from the client end. The server will be running on a standard
desktop PC.
Maybe I should use a different method. Would it be better if my "client"
machines were all servers and the "server" machine was actually accessing
multiple servers from the one client program? Is that even possible?
-Mike
|
|
| Back to top |
|
 |
Eugene Mayevski Guest
|
Posted: Fri Dec 31, 2004 12:26 am Post subject: Re: Finding a server on LAN |
|
|
Hello!
You wrote on Fri, 31 Dec 2004 09:10:21 +1000:
MW> Do you know of an example or more information to start me on
MW> learning how to use UDP broadcast.
UDP broadcast is a UDP packet sent to 255.255.255.255. One thing to remember
is that, as Remy said, the packets can be kiiled by some routers. So the
best thing to do is for the server to register it's presence in some
database (be it AD, DNS or other type of namespace system) which has
predefined address. BTW why not let the users specify the name of the
computer, on which the server is started?
With best regards,
Eugene Mayevski
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Dec 31, 2004 12:35 am Post subject: Re: Finding a server on LAN |
|
|
"Mike Warren" <miwaNOSPAM (AT) iprimus (DOT) com.au> wrote
| Quote: | The clients are setup by DHCP
|
That does not matter. That only effects the client's locally-assigned IP.
That does not effect the client's ability to connect to other machines on
the same network, or on the Internet if the DHCP server also has routing
capabilities.
| Quote: | and have no user access so I can't do anything from the client end.
|
Yes, you can. The UDP approach mentioned earlier is initiated from the
client end. A client can send out a single UDP packet over the entire
subnet. If your server is on the same subnet (or at least is reachable if
the network routers allow UDP broadcasts to pass through), the server can
receive the message and send its current IP address back to the client that
sent the broadcast. The client can then receive that message and connect to
the specified IP accordingly.
| Quote: | The server will be running on a standard desktop PC.
|
Does it have static IP, or at least a DNS-reachable hostname? This is
exactly the kind of scenerio that DNS was designed for. If your network has
a DNS server available, you can register a static hostname on it for the
server PC, and the clients can then do DNS queries to find out what the
current IP is.
| Quote: | Would it be better if my "client" machines were all servers and the
"server" machine was actually accessing multiple servers from the
one client program?
|
That approach requires the server to be explicitally configured to know the
IP of every client that wants to use the server. A much different
architecture then having all of your clients connect to the server instead.
Gambit
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Dec 31, 2004 12:36 am Post subject: Re: Finding a server on LAN |
|
|
"Mike Warren" <miwaNOSPAM (AT) iprimus (DOT) com.au> wrote
| Quote: | I won't know anything about the network it is going to be on.
|
Doesn't matter. As long as the client and server are on the same network,
and there are no routers in between blocking the packets, then it will
usually work fine.
Gambit
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Dec 31, 2004 12:55 am Post subject: Re: Finding a server on LAN |
|
|
"Eugene Mayevski" <mayevski (AT) eldos (DOT) org> wrote
| Quote: | BTW why not let the users specify the name of the computer,
on which the server is started?
|
I agree. If a user wants to connect the client to a server, the user should
specify where the server is located. This is much more flexible and
accurate than using UDP, which is not a reliable transport in the first
place.
Gambit
|
|
| Back to top |
|
 |
Mike Warren Guest
|
Posted: Fri Dec 31, 2004 1:03 am Post subject: Re: Finding a server on LAN |
|
|
| Quote: | BTW why not let the users specify the name of the computer,
on which the server is started?
I agree. If a user wants to connect the client to a server, the user
should specify where the server is located. This is much more
flexible and accurate than using UDP, which is not a reliable
transport in the first place.
|
That's my problem. The "client" machines are just boxes with no
user interface running WinXP. They have a random computer name
and dynamic IP address.
What I need is to be able to access several of these machines from
one desktop computer in an existing network to transfer data to and
from them.
Perhaps there is a better way of doing this?
-Mike
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Dec 31, 2004 1:12 am Post subject: Re: Finding a server on LAN |
|
|
"Eugene Mayevski" <mayevski (AT) eldos (DOT) org> wrote
| Quote: | UDP broadcast is a UDP packet sent to 255.255.255.255.
|
That depends. "255.255.255.255" is not always available or allowed
(multiple NICs present, admin configurations, etc). In those cases, you
have to calculate the broadcast address dynamically in order for the packet
to be routed correctly. You would use the sender's own IP and subnet mask
to calculate the target broadcast address, using the following algorithm:
BroadcastIP := (SenderIP and SubnetMask) or (not SubnetMask);
So, for example, on my home network I have an IP of 192.168.1.101 and a
subnet of 255.255.255.0, so my broadcast address would be 192.168.1.255.
Since I have multiple NICs installed, the packet can be routed to the
appropriate network. If you use 255.255.255.255 with multiple NICs present,
there are three possible outcomes:
1) the packet may be sent to all connected networks, creating more network
traffic then needed
2) the packet may be sent to none of the connected networks, failing the
broadcast
3) the packet may go to the wrong network since the OS does not know which
NIC is supposed to be used to send the packet, so it makes a (somewhat
educated) guess as to which NIC to use.
Gambit
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Dec 31, 2004 1:20 am Post subject: Re: Finding a server on LAN |
|
|
"Mike Warren" <miwaNOSPAM (AT) iprimus (DOT) com.au> wrote
| Quote: | That's my problem. The "client" machines are just boxes
with no user interface running WinXP. They have a random
computer name and dynamic IP address.
|
Why do they have random names? DHCP clients can have static computer names
assigned to them. You can then use DNS to find their assigned IP addresses.
| Quote: | What I need is to be able to access several of these machines from
one desktop computer in an existing network to transfer data to and
from them.
|
Your design is backwards then. Each of the XP machines should be running
server sockets, not client sockets, and the desktop PC should have a
separate client socket for each XP machine that it wants to access. That
way, you just specify to the desktop application which computer names you
want to access, and it connects to each one accordingly.
If static computer names are not available (a very bad idea, but so be it),
you can still use the UDP approach that has already been described to you.
Have each XP machine running a UDP server on a specific port number. The
desktop application can send a UDP broadcasted packet to the network on that
port number. When each XP machine receives the packet, it can report back
its currently assigned IP address. The desktop application can then build
up a list of the available XP machines that it can connect to based on the
responses that it receives.
Gambit
|
|
| Back to top |
|
 |
Ben Hochstrasser Guest
|
Posted: Fri Dec 31, 2004 1:21 am Post subject: Re: Finding a server on LAN |
|
|
Mike Warren wrote:
| Quote: | That's my problem. The "client" machines are just boxes with no
user interface running WinXP. They have a random computer name
and dynamic IP address.
What I need is to be able to access several of these machines from
one desktop computer in an existing network to transfer data to and
from them.
Perhaps there is a better way of doing this?
|
As these computers have DHCP they probably know about a name server. All
you have to do is to create an alias (CNAME) for your own server and have
(via a service) the clients contacting the server behind that name and
register themselves (open a connection to a specific port where they wait
for instructions, for example).
If you haven't got any DNS, use some rarely-used DHCP option (eg "impress
server") and let the clients contact that one.
These things require some stuff to be installed onto these clients in the
first place. If that is not an option, scan the subnet, remotely open
registries and look for distinctive keys/values.
--
Ben
|
|
| Back to top |
|
 |
Mike Warren Guest
|
Posted: Fri Dec 31, 2004 1:40 am Post subject: Re: Finding a server on LAN |
|
|
| Quote: | That's my problem. The "client" machines are just boxes
with no user interface running WinXP. They have a random
computer name and dynamic IP address.
Why do they have random names? DHCP clients can have static computer
names assigned to them. You can then use DNS to find their assigned
IP addresses.
|
The names are random when the machines are built but don't change each time
they boot. I can probably supply a list of computer names that match each
machine.
| Quote: | What I need is to be able to access several of these machines from
one desktop computer in an existing network to transfer data to and
from them.
Your design is backwards then. Each of the XP machines should be
running server sockets, not client sockets, and the desktop PC should
have a separate client socket for each XP machine that it wants to
access.
|
I thought that might be the case. I'll work in that direction. Since I don't
know in advance how many machines may be available, should I create
TidTCPClient components dynamically?
-Mike
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Dec 31, 2004 2:15 am Post subject: Re: Finding a server on LAN |
|
|
"Mike Warren" <miwaNOSPAM (AT) iprimus (DOT) com.au> wrote
| Quote: | The names are random when the machines are built
but don't change each time they boot.
|
Then they are, in fact, static names. You can specify those names when your
desktop application wants to connect to them. Then you do not need to know
the IP addresses at all. The OS will handle the IP lookup internally for
you.
| Quote: | Since I don't know in advance how many machines may be
available, should I create TidTCPClient components dynamically?
|
Assuming that you want to connect to multiple machines at one time, then
yes. If you are connecting to them one at a time, however, then you can
re-use a single TIdTCPClient instance.
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|