Friday, June 8, 2012
Network Scanner
Okay, i have achieved a part of my dreams in coding today. I've always wanted to write nifty little network tools that serve a purpose, today, I have actually written one, well at least the draft of a proof of concept for a larger project.
Two key reference that I used to generate the code was:
http://www.xtremevbtalk.com/showthread.php?t=321718
1: Imports System
2: Imports SnmpSharpNet
3: Public Class Form1
4: Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
5: 'check if keyed fields contain numeric only data,stop if they don't
6: If Not IsNumeric(Me.tb_f_o1.Text) Then Exit Sub
7: If Not IsNumeric(Me.tb_f_o2.Text) Then Exit Sub
8: If Not IsNumeric(Me.tb_f_o3.Text) Then Exit Sub
9: If Not IsNumeric(Me.tb_f_o4.Text) Then Exit Sub
10: If Not IsNumeric(Me.tb_t_o1.Text) Then Exit Sub
11: If Not IsNumeric(Me.tb_t_o2.Text) Then Exit Sub
12: If Not IsNumeric(Me.tb_t_o3.Text) Then Exit Sub
13: If Not IsNumeric(Me.tb_t_o4.Text) Then Exit Sub
14: tb_results.Text += "start" & vbCrLf
15: 'convert text box values to integers
16: Dim a_to As Integer = CInt(Me.tb_t_o1.Text)
17: Dim a_from As Integer = CInt(Me.tb_f_o1.Text)
18: Dim b_to As Integer = CInt(Me.tb_t_o2.Text)
19: Dim b_from As Integer = CInt(Me.tb_f_o2.Text)
20: Dim c_to As Integer = CInt(Me.tb_t_o3.Text)
21: Dim c_from As Integer = CInt(Me.tb_f_o3.Text)
22: Dim d_to As Integer = CInt(Me.tb_t_o4.Text)
23: Dim d_from As Integer = CInt(Me.tb_f_o4.Text)
24: ' Use Parse() to convert from the integers to an IPAddress.
25: Dim fromAddress As System.Net.IPAddress = System.Net.IPAddress.Parse(a_from & "." & b_from & "." & c_from & "." & d_from)
26: Dim toAddress As System.Net.IPAddress = System.Net.IPAddress.Parse(a_to & "." & b_to & "." & c_to & "." & d_to)
27: ' We need the integral value of the IP. The Address property is deprecated. Use GetAddressBytes() and
28: ' convert the bytes to a value. If you are using IPv4, this should be 4 bytes, 32 bits, only Integer is needed.
29: Dim currentAddress As System.Net.IPAddress
30: Dim addressBytes() As Byte = fromAddress.GetAddressBytes()
31: Dim addressValue As Integer = BitConverter.ToInt32(addressBytes, 0)
32: Dim toaddressBytes() As Byte = toAddress.GetAddressBytes()
33: Dim toaddressValue As Integer = BitConverter.ToInt32(toaddressBytes, 0)
34: ' The bytes come out in network order; we don't want to figure out if that's backwards or not. Use this method
35: ' to convert to whatever the host machine uses.
36: addressValue = System.Net.IPAddress.NetworkToHostOrder(addressValue)
37: toaddressValue = System.Net.IPAddress.NetworkToHostOrder(toaddressValue)
38: For i = addressValue To toaddressValue
39: Dim thei As Integer = i
40: Dim theb() As Byte
41: ' We're ready to go back to bytes; convert the number back to network order
42: thei = System.Net.IPAddress.HostToNetworkOrder(thei)
43: ' Turn it back into bytes, create the new IP
44: theb = BitConverter.GetBytes(thei)
45: currentAddress = New System.Net.IPAddress(theb)
46: Dim thehostname As String
47: Try
48: thehostname = System.Net.Dns.GetHostEntry(currentAddress.ToString).HostName.ToString
49: Catch ex As Exception
50: thehostname = "Could not detect hostname"
51: End Try
52: tb_results.Text += " IP: " & currentAddress.ToString & " | Active: " & pinger(currentAddress.ToString) & " | Hostname: " & thehostname & vbCrLf
53: My.Application.DoEvents()
54: Next
55: tb_results.Text += "done" & vbCrLf
56: End Sub
57: Function pinger(ip As String)
58: If My.Computer.Network.Ping(ip) Then
59: Return (1)
60: Else
61: Return (0)
62: End If
63: End Function
I have a dream... about my future tablet.
These two urls showed the power that can be found in current windows 8 tablets.
I would ditch my ipad for this in a heartbeat. As a software developer, being able to have the ability to work with my native developer app (Visual Studio) and be able to play Diablo 3 ( a game that just came out last month, and that I plan to play for several years) as well as having full blown versions of all the applications I normally use rather than ‘apps’ appeals greatly to me.
http://www.drdobbs.com/mobile/232900072?vXFf&cid=sem_edit_DDJ&wc=4&vQZf
https://www.youtube.com/watch?v=ukn3wp3Dr-Q
Ideally, I would want to be able to take my tablet, dock it at home, and be able to plug at least 3 monitors into the dock.
Secondly, I would hope the dock would have a more powerful gpu, cpu, and possibly ram that pairs with the tablets hardware to provide more of a work horse when docked.
So that's my tablet dream for the day...
Subscribe to:
Posts (Atom)