Link to home
Start Free TrialLog in
Avatar of tvtech
tvtechFlag for Australia

asked on

See all PC's on my network

Hi,

My app sits on a shared Windows XP PC, which acts as a 'server' to a small office network.

I need the ability for my client apps, on the network, to locate the 'server' and populate a textbox with the 'server's' name. Can anyone point me to some code that does this, please.

Thanks.
Avatar of Aegil
Aegil
Flag of United Kingdom of Great Britain and Northern Ireland image

If the computer is being used as a server why dont you just set it up on a static ip address and use that as the reference in your application, or just the machine name. Unless you are wanting that the server changes frequently, I know in standard server / client apps you would want a fixed server name / ip usually. Further to that, the computers name (i guess you mean hostname) shouldnt really change regularly.
Aegil is right, you would normally set the server to be something static - so that you always know what it is.  So when you think about "acts as a 'server'", what is the definition of "server" in this case?  Literally.  Does it run a certain piece of software?  If so, maybe you can have to do something that announces itself as the "server".  And to do so, you'd have to have a common place/method to make that announcement.  For instance, if all workstations share a common network drive, such as F:\, then you could say that all clients agree to look at F:\Server.txt, read the contents to find out what they need to know to identify the server. Then you jst work backwards and make your server setup that file when it starts, effectively announcing, "I'm the server."
Avatar of tvtech

ASKER

Sorry guys, I should have said that my Client apps all need to locate the server app. Something along the lines of listing all network PC's in a listbox and letting the user select the 'server' PC, so that my client apps can all talk to the 'server' app.
so are you going to have servers on every single pc and a client on every single pc?
And then you want the client to be able to find a list of all pcs with server apps running on them and then allow the user to be able to connect to the specific one they want?

Could we ask what your app is for? or an idea of what its supposed to do?
Avatar of tvtech

ASKER

No. One PC acts as a server, which carries a mySQL database. The client PC's, using ADO, access that mySQL DB, but they (Clients) need to know where the server is, without user interaction.

The idea is that once the server app is installed, it will drop a file into it's folder, with the PC name contained within it.

As each client app is installed, it looks for the file that resides in the server folder. It then knows the permanent server name, so that it can be used in the mySQL connectstring.

Thanks.
It seems a lot more work than simply having a set name . All you really need to do is program your software to auto install with a default server hostname. You can just call the server pc SERVER as a hostname and get your software to use that. I mean if its just one server, just set that server as a static IP and a set hostname and then proceed based on that if its just a case of one site that will use this application.

For example in a windows environment where you dont have AD and are connecting to an exchange server. for example when a user uses there own laptop they would put in the server name to configure there mailbox anyways. I would probable recommend you just set your software to try a default name, set the server to use that same name. And have a feature for updating the server name in your software.

I mean the way you seem to be wanting to do it, your going to have your server drop a file into its folder, the application is going to scan the network for a shared folder or some application socket to retrieve the hostname to then populate the ADO connection string automatically.
Avatar of tvtech

ASKER

Thanks, but it will be a number of sites, most of which will be too far for us to visit and setup.

Yes, it does seem like a lot of work, but bear in mind that good software is not always based on the easiest, or safest approach, from a programming perspective. :-)

Our apps talk to each other, via both local and Net based mySQL databases. We need to minimise user interaction, due to the fact that they are complete novices. Setting up static IP's is not an option, due to user lack of knowledge and possible unknowns.

Thanks.
I may have a solution that find all pc's on a network and populated a combo box, but I'll be away from my computer until later tonight.  I'll try to post it as soon as I can.
Here is the sample I used to make an app that loads a list of all computers on the network.  And it's pretty fast, even over a VPN.

http://www.daniweb.com/software-development/visual-basic-4-5-6/code/216297

(It's attached for reference purposes.)
basGetComputers-v2.bas
ASKER CERTIFIED SOLUTION
Avatar of kbirecki
kbirecki
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial