C# Network Programming Question
Hello, I have a C# question. I have a System.Net.IPAddress and I need to convert the end of it, ie: 192.168.1.xxx to an integer. I plan to loop through like this:
for(int i=0; i<256; i++) {
IPAddress = 192.168.1.i;
}
How can I do this? I''ve tried converting it to a string and trying to fidgit it that way but the fact that the returned string can be 192.168.1.1 or 192.168.1.11 or 192.168.1.111 makes it an unelegant solution (which I can''t get to work).
Is there any other way to do this? I can''t believe this kindof thing isn''t programmed into the .Net framework, and if it is then it has certainly alluded.
Thanks in advance, I would appreciate any ideas.
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
If I were you, I''d do the following.
Kami no Itte ga ore ni zettai naru!
IPAddress ip;for (int i = 0; i < 256; ++i) { ip = IPAddress.Parse("192.168.1." + i.ToString()); // Do whatever with the ip }// next
Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
But do all networks have the prefix 192.168.1?
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
quote:
Original post by 31337
But do all networks have the prefix 192.168.1?
All hosts on the 192.168.1.0 network with subnet mask 255.255.255.0 do... heh.
Though I question why you would want to mass generate IP addresses, please don't make some kind of spammer/scanner unless you have a good purpose and intention, and if you are trying to broadcast, figure out the broadcast address for the interface rather than manually sending to each IP.
[edited by - rdragon1 on February 26, 2004 9:59:21 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement