|
Thanks.
I think I also need a test statement to check if the directory exists. If it does not exist, then create the directory. Otherwise, just write the file in the directory.
What is the statement for checking if a directory exist ?
Thanks again
|
|
|
|
|
mrby123 wrote: What is the statement for checking if a directory exist ?
You could either call _access() or let CreateDirectory() do it for you.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
As Maximilien said, programs are normally installed under the C:\Program Files directory.
You need administrative privileges to create folders and files under this directory.
You can get the Documents folder using the SHGetSpecialFolderLocation API and specifying CSIDL_MYDOCUMENTS in its nFolder parameter.
|
|
|
|
|
How can I find multiple servers Listening on our college LAN using TCP socket ?
my loop will run from ip 192.168.100.0 to 192.168.120.255.
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
The only existing technique is port scanning i.e. connect to each and everyone of them. You may wish to use threads, as response time outs will slow you down.
|
|
|
|
|
Suppose I create a thread for every subnet. .then
How many TCP sockets should i use (Per thread) ?
My loop is like this -
for(;;)
{for(;;)
{for(;;)
{for(;;)
{
connect(MySocket, ...);
}
}
}
}
then how do i decide socket's TIMEOUT if i use single socket per thread ?
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
I don't know, I've never done it I suppose it will depend on the number that answer vs the number that do not answer.
Trial and error, and selectable parameters are your friend here...
Oh, and I hope your targeting a specific port because scanning 5000 hosts * 65535 ports is going to take a long time.
|
|
|
|
|
Manmohan29 wrote: from ip 192.168.100.0 to 192.168.120.255
If you simply want to find all connected hardware addresses in this range then I would suggest using ARP[^]. The IP Helper function SendARP Function[^] is very easy to use and will quickly tell you if there is a MAC address associated with the IP. Once you have determined there is a networked device on the other side you can begin your TCP negotiation.
Best Wishes,
-David Delaune
|
|
|
|
|
You can't arp a subnet over a router.
|
|
|
|
|
Hi Michel,
The author clearly states he is on a LAN.
Best Wishes,
-David Delaune
|
|
|
|
|
And you think a lan with 5100 potential hosts has no hubs and switches? At home I can't even arp the server in the next room because there's a switch in between.
|
|
|
|
|
Hi Michael,
Michel Godfroid wrote: At home I can't even arp the server in the next room because there's a switch in between.
Then perhaps you should consider replacing your hardware. If ARP packets cannot pass through your switch then how does your networked devices communicate?
Best Wishes,
-David Delaune
|
|
|
|
|
This is really off-topic, but allow me this short explanation:
ARP is a layer 2 protocol (the MAC layer in Ethernet technologies). It establishes the relationship between layer 2 (Media Access Control) and layer 3 (the network layer in the OSI model, or the Internet Layer (typically IP)) The only way you will have an arp entry in your arp cache is as follows:
1) you issue a broadcast on your (IP) subnet, requesting the owner of a specific IP address to tell you it's mac address (or the mac address it can reach). The telecommunication equipment which may sit in between you and the destination will reply with either it's own mac address(if it knows it can switch your packets to the final destination), or with the real MAC address of the equipment, if it's a dumb component like a hub, or the final (directly connected) component in the chain.
2) the other component has queried you (probably through broadcast) for your address. In that case the Arp cache will associate the querying MAC address with the querying IP address.
The whole point of modern communication equipment, as opposed to old stuff (like hubs) is to limit the number of broadcasts and packet traffic on segments (segments, not subnets). Broadcasts are limited to a segment, and traffic is directed on the wire. With some modern intelligent switches, it is even possible to have duplicate MAC addresses on the network, as long they are not in the same segment. (I wouldn't recommend it though...)
So in the context of this discussion:
Walking the arp table, you'll miss all the hosts which are on a different subnet (you still need routers for making subnets), you may miss hosts which are on a different segment, and you'll miss hosts on your own segment if you haven't contacted them before their arp entry became stale. Otherwise, it's a fine technique.
|
|
|
|
|
Hi Michael,
You never answered my question:
If ARP packets are unable to traverse across your switch then how are your network devices communicating?
Michel Godfroid wrote: The only way you will have an arp entry in your arp cache
I am not sure why you are writing all of this gibberish. It is not even completely correct.
Why do you feel the need to debate?
Best Wishes,
-David Delaune
|
|
|
|
|
My only point is that you cannot use arp to DISCOVER servers on the Internet layer. They will only be there if you've discovered them before, and anyway servers on other subnets will never be there. You discover an ARP entry by querying an IP address, not the other way round...
|
|
|
|
|
Hi,
As I stated in my second post:
The author of the question clearly states that he is attempting to scan the LAN for network devices. ARP is a very good candidate for scanning the local network for hardware addresses. In fact this is how the Microsoft NDIS layer works... the first thing TCPIP.SYS does is send an ARP broadcast if there is no entry in the table.
Here on codeproject.com we are all experienced developers sharing our experience and knowledge for free. In my opinion it is not very good etiquette to attack other posters who are assisting.
Best Wishes,
-David Delaune
P.S.
You still have not answered my question. And its because ARP broadcasts DO pass through your switch.
|
|
|
|
|
Fixed the low votes on your posts (and marked the query as answered).
PS: It seem to work on my LAN and I'm in agreement with you.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Ouch... voting up a user who gives wrong technical advice is not a good idea!
There is a difference in LANs that consist of one subnet and those with multiple subnets (where ARP traffic will not be forwarded but IP traffic will be) as explained by Michel Godfroid.
Chat in Europe Now with 24% more Twitter
modified on Monday, May 10, 2010 3:42 PM
|
|
|
|
|
Hi Moak,
Moak wrote: There is a difference in LANs that consist of one subnet and those with multiple subnets (where APR traffic will not be forwarded but IP traffic will be) as explained by Michel Godfroid.
This is not correct. The switch *will* forward the ARP broadcast. The network device on the other side however will not respond if it is on another subnet.
Best Wishes,
-David Delaune
|
|
|
|
|
Have you considered network topologies with L3 routers, a campus LAN must not only consist of L2 hubs/switches?
|
|
|
|
|
Hi Moak,
Absolutely. I simply wanted to add additional options on top of the advice by Michel Godfroid. I did not expect such a strong negative response.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David!
You give a lot of helpful advice, just recently I learned something about Linux system calls form a very detailed posting of you! This time the advice you gave doesn't work in a typical campus LAN which is the original posters scenario (multiple /24 subnets). The initial replies from Michael mentioned that such a network topology probably has L3 routing and explained the background why ARP in such a scenario will not be able to enumerate all active hosts.
You can give it a try with nmap -PR -oN arpscan.txt 192.168.0.0/16 , which is expected not to work in a larger network. It should be okay among us to correct technical details and give together the best technical advice. Please don't see my response as negative, it really wasn't meant bad in any way.
Best regards
/Moak
Chat in Europe Now with 24% more Twitter
modified on Tuesday, May 11, 2010 3:16 AM
|
|
|
|
|
Moak wrote: There is a difference in LANs that consist of one subnet and those with multiple subnets (where APR traffic will not be forwarded but IP traffic will be) as explained by Michel Godfroid.
While the OP hasn't been particularly clear about his setup, it's hard for someone to guess and answer. While Michel's answer is correct (and carries my "good answer" vote), I see very little reason to lynch-vote David's post.
I'd leave it to the OP to decide if it were wrong technical advice in this case by testing the suggestions offered in his setup, as he's not provided sufficient details for the responders.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Moak wrote: (where APR traffic will not be forwarded but IP traffic will be
Nitpicking: BTW, that ought to be ARP traffic.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
If you want to add a reply, keep it public. Do not delete it after you've posted something!
Workout progress:
Current arm size: 14.4in
Desired arm size: 18in
Next Target: 15.4in by Dec 2010
Current training method: HIT
|
|
|
|