I want to get the IP address of devices which's are on my wireless network, 开发者_开发百科and I want to detect when someone connects to the network.
How can handle network connection in C#?
Since "you" are not the router (or whatever kind wireless dispatcher it is) there is no safe way for you to learn when someone connects to the network. Sure most OSes would broadcast their connection on the network and such, but it's not "mandatory" to do so. What I would suggest is to query all the possible IP addresses.
WAIT! Don't scream yet.
My guess is that you're aware of the wireless IP address range of the network, which I guess shouldn't be THAT big. If you do some kind of ping on a timer on each IP address, you won't know exactly when the client connected, but you'll know he's there. This is true only if the router don't block the pings on the LAN and if the clients accept to respond to the ping.
精彩评论