Scanning for hosts.

This is a discussion on Scanning for hosts. within the Networking/Device Communication forums, part of the General Programming Boards category; Hi, First up, my apologies if this question is either ludicrously simple, or in the wrong place! Anyhow, I'm trying ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Location
    Northamptonshire, UK
    Posts
    18

    Question Scanning for hosts.

    Hi,

    First up, my apologies if this question is either ludicrously simple, or in the wrong place!

    Anyhow, I'm trying to develop an application which will allow me as the instructor on a technical training class to automatically mark labs completed by students in the class. As part of this, I need to pull up a list of all the windows machines currently available on the network (isolated segement for the classroom).

    What I need to do is to find out the machine names of all currently running machines - either from WINS or directly by scanning the network. (at worst a class C network)

    How do I do this? I've seen other applications do similar things (as does Windows itself) so I know it CAN be done, but how?

    If it matters, I'm useing Code::Blocks and wxWidgets to develop.

    Thanks for reading this, all responses gratefully received.

  2. #2
    FOSS Enthusiast
    Join Date
    Jun 2008
    Location
    Germany
    Posts
    64
    if you're using Windows (I suppose since you mentioned WINS), I guess you could take a look on the specifiactions of either NetBIOS or SMB. One of the two implements the Windows-Computernames and I bet there's even a function in the Windows API to get the Hosts in a specified network.
    And if that didn't work, you can take a look at the samba sourcecode. They somehow implemented it, so you can take a look on how they did.

    Sorry if that answer is a little inprecise, but I've never done things like this before. Well, I did something similar, but I used a server which collected messages and each machine was running a client which sent a message every 30 seconds to the server, to determine it's still online. Then every 600 seconds, the server created a web page (xhtml 1.0 strict & css 2.1 compliant ) showing all hosts that sent a message. But also, the clients were to specify a nickname, so it's not necessarily the hostname. Though that can be changed very simple using getenv().

    So I'm not using something like NetBIOS, WINS or SMB, but for experimental purposes, it was working.
    If you're interested in the sourcecode, I'll make a package containing both server and client

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    If you already know all the hostnames of the computers on your network, you can use the ICMP protocol to ping the hostnames. For instance, you could use an ASCII text file containing the hostnames as input to the ICMP ping utility. It would ping each hostname in the file and determine whether or not it is up and running. If this is a viable option, I can send you the complete source code for this ICMP utility.

  4. #4
    Registered User
    Join Date
    Jan 2007
    Location
    Northamptonshire, UK
    Posts
    18
    Thanks, both of you...

    Hummm.

    Reading the source code for SAMBA - not for the faint-hearted!! I wouldn't even know where to start on that one ;-)

    Pinging - I could do this, although I don't neccessarily know the list of machines that could be there. This will vary from room to room and I don't want to hard-code anything like this since, as a company, we are expanding.

    I guess what I could do is to scan the whole network (pick up the net number and subnet mask) and ping every device. Those that respond I could check if the SMB ports are open. That would tell me which are valid hosts. I guess reverse DNS would then get me the name.

    Nice theory, but how would I do this in practice? I'd be interested to see your ICMP ping code. Cany anyone shed any light on the portscan / reverse DNS part?

    Alternatively, can't I simply ask the wins server? It must be possible since even Windoze itself can show you currently visible machines!! (Net. N'hood) Again, no idea how to achieve this, though.

    Cheers,

    Paul

  5. #5
    FOSS Enthusiast
    Join Date
    Jun 2008
    Location
    Germany
    Posts
    64
    like I said, network neighborhood in windows is managed using SMB or NetBIOS.. I dont know which of the two its it, but it's one of those. And since Microsoft released the specifications for SMB, it shouldn't be such a big deal.
    Well no matter what, It's not such a big task, but please don't ask for details right now because Germany just entered the finals for the European Championships and I've drank quite a bit ;D

    Of course, if you need a viable answer, most people can help you on this boards right now. But just in case you want to code your own client/server system like I did, I could help you. Not to mention it's much easier to achieve than reading NetBIOS or SMB specifications.

    So, no matter what, I wish everyone a good night

  6. #6
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    I'd be interested to see your ICMP ping code
    PM me with an email address and I will send you complete source code in a zip file.

  7. #7
    FOSS Enthusiast
    Join Date
    Jun 2008
    Location
    Germany
    Posts
    64
    you could also take a look at the ping sourcecode from the GNU Inetutils

  8. #8
    Registered User
    Join Date
    Jan 2007
    Location
    Northamptonshire, UK
    Posts
    18
    Thanks, Bob! I tried but it says you don't accept PMs...

    Can you PM me with yours and I'll e-mail you?

    Cheers,

    Paul

  9. #9
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    I tried but it says you don't accept PMs...
    Sorry about that. I just got tired of receiving a lot of nuisance PM's So, I disabled it. I sent you my email address

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Scanning a list?
    By scarlet00014 in forum C Programming
    Replies: 4
    Last Post: 10-15-2008, 04:25 PM
  2. Scanning cloth.
    By adrianxw in forum Tech Board
    Replies: 3
    Last Post: 04-26-2005, 11:59 AM
  3. scanning in character string
    By zackboll in forum C Programming
    Replies: 12
    Last Post: 11-24-2004, 02:18 AM
  4. scanning in with gets() but not over inputing
    By stephanos in forum C Programming
    Replies: 1
    Last Post: 09-09-2002, 04:38 PM
  5. stopping some scanning
    By aoe in forum C Programming
    Replies: 4
    Last Post: 06-09-2002, 02:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21