Dim u_cksum As UInt16
u_cksum = checksum(MyBuffer, cksum_buffer_length)
Becouse checksum is an array and u_cksum is not
can u tellme how to fix your example code?
"Richard T. Edwards" <r.t.e...@attbi.com> wrote in message news:eNav9.143113$%d2.51429@sccrnsc01...
> Here's Ping VB.Net Style
>
> Imports System
>
> Imports System.Runtime.InteropServices
>
> Imports System.Net
>
> Imports System.Net.Sockets
>
> Public Class Form1
>
> Inherits System.Windows.Forms.Form
>
> #Region " Windows Form Designer generated code "
>
> Public Sub New()
>
> MyBase.New()
>
> 'This call is required by the Windows Form Designer.
>
> InitializeComponent()
>
> 'Add any initialization after the InitializeComponent() call
>
> End Sub
>
> 'Form overrides dispose to clean up the component list.
>
> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
>
> If disposing Then
>
> If Not (components Is Nothing) Then
>
> components.Dispose()
>
> End If
>
> End If
>
> MyBase.Dispose(disposing)
>
> End Sub
>
> 'Required by the Windows Form Designer
>
> Private components As System.ComponentModel.IContainer
>
> 'NOTE: The following procedure is required by the Windows Form Designer
>
> 'It can be modified using the Windows Form Designer.
>
> 'Do not modify it using the code editor.
>
> Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
>
> Friend WithEvents Label1 As System.Windows.Forms.Label
>
> Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
>
> Friend WithEvents Label2 As System.Windows.Forms.Label
>
> Friend WithEvents Button1 As System.Windows.Forms.Button
>
> Friend WithEvents Label3 As System.Windows.Forms.Label
>
> Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
>
> Friend WithEvents Label4 As System.Windows.Forms.Label
>
> Friend WithEvents Button2 As System.Windows.Forms.Button
>
> Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
>
> Friend WithEvents ListBox2 As System.Windows.Forms.ListBox
>
> Friend WithEvents ListView1 As System.Windows.Forms.ListView
>
> Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader
>
> Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader
>
> <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
>
> Me.StatusBar1 = New System.Windows.Forms.StatusBar()
>
> Me.Label1 = New System.Windows.Forms.Label()
>
> Me.TextBox1 = New System.Windows.Forms.TextBox()
>
> Me.Label2 = New System.Windows.Forms.Label()
>
> Me.Button1 = New System.Windows.Forms.Button()
>
> Me.Label3 = New System.Windows.Forms.Label()
>
> Me.TextBox4 = New System.Windows.Forms.TextBox()
>
> Me.Label4 = New System.Windows.Forms.Label()
>
> Me.Button2 = New System.Windows.Forms.Button()
>
> Me.ListBox1 = New System.Windows.Forms.ListBox()
>
> Me.ListBox2 = New System.Windows.Forms.ListBox()
>
> Me.ListView1 = New System.Windows.Forms.ListView()
>
> Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader()
>
> Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader()
>
> Me.SuspendLayout()
>
> '
>
> 'StatusBar1
>
> '
>
> Me.StatusBar1.Location = New System.Drawing.Point(0, 638)
>
> Me.StatusBar1.Name = "StatusBar1"
>
> Me.StatusBar1.Size = New System.Drawing.Size(800, 16)
>
> Me.StatusBar1.TabIndex = 0
>
> Me.StatusBar1.Text = "StatusBar1"
>
> '
>
> 'Label1
>
> '
>
> Me.Label1.Location = New System.Drawing.Point(0, 16)
>
> Me.Label1.Name = "Label1"
>
> Me.Label1.Size = New System.Drawing.Size(88, 16)
>
> Me.Label1.TabIndex = 2
>
> Me.Label1.Text = "Machine Name:"
>
> Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
>
> '
>
> 'TextBox1
>
> '
>
> Me.TextBox1.Location = New System.Drawing.Point(96, 16)
>
> Me.TextBox1.Name = "TextBox1"
>
> Me.TextBox1.Size = New System.Drawing.Size(152, 20)
>
> Me.TextBox1.TabIndex = 3
>
> Me.TextBox1.Text = ""
>
> '
>
> 'Label2
>
> '
>
> Me.Label2.Location = New System.Drawing.Point(0, 40)
>
> Me.Label2.Name = "Label2"
>
> Me.Label2.Size = New System.Drawing.Size(88, 16)
>
> Me.Label2.TabIndex = 4
>
> Me.Label2.Text = "Local IP"
>
> Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
>
> '
>
> 'Button1
>
> '
>
> Me.Button1.Location = New System.Drawing.Point(696, 296)
>
> Me.Button1.Name = "Button1"
>
> Me.Button1.Size = New System.Drawing.Size(72, 64)
>
> Me.Button1.TabIndex = 6
>
> Me.Button1.Text = "Ping"
>
> '
>
> 'Label3
>
> '
>
> Me.Label3.Location = New System.Drawing.Point(264, 40)
>
> Me.Label3.Name = "Label3"
>
> Me.Label3.Size = New System.Drawing.Size(120, 16)
>
> Me.Label3.TabIndex = 9
>
> Me.Label3.Text = "Local IP"
>
> Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
>
> '
>
> 'TextBox4
>
> '
>
> Me.TextBox4.Location = New System.Drawing.Point(400, 16)
>
> Me.TextBox4.Name = "TextBox4"
>
> Me.TextBox4.Size = New System.Drawing.Size(152, 20)
>
> Me.TextBox4.TabIndex = 8
>
> Me.TextBox4.Text = ""
>
> '
>
> 'Label4
>
> '
>
> Me.Label4.Location = New System.Drawing.Point(264, 16)
>
> Me.Label4.Name = "Label4"
>
> Me.Label4.Size = New System.Drawing.Size(128, 16)
>
> Me.Label4.TabIndex = 7
>
> Me.Label4.Text = "Machine Name:"
>
> Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
>
> '
>
> 'Button2
>
> '
>
> Me.Button2.Location = New System.Drawing.Point(568, 16)
>
> Me.Button2.Name = "Button2"
>
> Me.Button2.Size = New System.Drawing.Size(80, 64)
>
> Me.Button2.TabIndex = 11
>
> Me.Button2.Text = "Resolve IP"
>
> '
>
> 'ListBox1
>
> '
>
> Me.ListBox1.Location = New System.Drawing.Point(400, 40)
>
> Me.ListBox1.Name = "ListBox1"
>
> Me.ListBox1.Size = New System.Drawing.Size(152, 134)
>
> Me.ListBox1.TabIndex = 12
>
> '
>
> 'ListBox2
>
> '
>
> Me.ListBox2.Location = New System.Drawing.Point(96, 40)
>
> Me.ListBox2.Name = "ListBox2"
>
> Me.ListBox2.Size = New System.Drawing.Size(152, 134)
>
> Me.ListBox2.TabIndex = 13
>
> '
>
> 'ListView1
>
> '
>
> Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader()
> {Me.ColumnHeader1, Me.ColumnHeader2})
>
> Me.ListView1.GridLines = True
>
> Me.ListView1.Location = New System.Drawing.Point(8, 296)
>
> Me.ListView1.Name = "ListView1"
>
> Me.ListView1.Size = New System.Drawing.Size(672, 80)
>
> Me.ListView1.TabIndex = 14
>
> Me.ListView1.View = System.Windows.Forms.View.Details
>
> '
>
> 'ColumnHeader1
>
> '
>
> Me.ColumnHeader1.Text = "IP Address"
>
> Me.ColumnHeader1.Width = 78
>
> '
>
> 'ColumnHeader2
>
> '
>
> Me.ColumnHeader2.Text = "Address Family"
>
> Me.ColumnHeader2.Width = 149
>
> '
>
> 'Form1
>
> '
>
> Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
>
> Me.ClientSize = New System.Drawing.Size(800, 654)
>
> Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ListView1,
> Me.ListBox2, Me.ListBox1, Me.Button2, Me.Label3, Me.TextBox4, Me.Label4,
> Me.Button1, Me.Label2, Me.TextBox1, Me.Label1, Me.StatusBar1})
>
> Me.Name = "Form1"
>
> Me.Text = "Form1"
>
> Me.ResumeLayout(False)
>
> End Sub
>
> #End Region
>
> Public Class IcmpPacket
>
> Public Type As Byte ' type of message
>
> Public SubCode As Byte ' type of sub code
>
> Public CheckSum As UInt16 ' ones complement checksum of struct
>
> Public Identifier As UInt16 'identifier
>
> Public SequenceNumber As UInt16 ' sequence number
>
> Public Data As Byte()
>
> End Class
>
> Declare Auto Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Dest
> As Integer, ByVal Src As Integer, ByVal L As Integer)
>
> Private Declare Function GetComputerName Lib "Kernel32.dll" Alias
> "GetComputerNameA" (<MarshalAsAttribute(UnmanagedType.LPArray)> ByVal
> LPBuffer() As Byte, <MarshalAsAttribute(UnmanagedType.LPArray)> ByVal
> nSize() As Int32) As Long
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> Dim str(20) As Byte
>
> Dim len(1) As Int32
>
> Dim iret As Long
>
> len(0) = 20
>
> Dim pstr As String
>
> Dim lcldnslst As IPHostEntry
>
> Dim lclIp() As IPAddress
>
> Dim i As Integer
>
> iret = GetComputerName(str, len)
>
> TextBox1.Text = System.Text.Encoding.ASCII.GetString(str)
>
> lcldnslst = Dns.GetHostByName(TextBox1.Text)
>
> lclIp = lcldnslst.AddressList
>
> For i = 0 To lclIp.Length - 1
>
> ListBox2.Items.Add(lclIp(i).ToString())
>
> Next
>
>
>
> End Sub
>
> Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles TextBox4.TextChanged
>
>
>
> End Sub
>
> Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button2.Click
>
> Dim lcldnslst As IPHostEntry
>
> Dim lclIp() As IPAddress
>
> Dim i As Integer
>
> ListBox1.Items.Clear()
>
> Try
>
> lcldnslst = Dns.GetHostByName(TextBox4.Text)
>
> lclIp = lcldnslst.AddressList
>
> For i = 0 To lclIp.Length - 1
>
> ListBox1.Items.Add(lclIp(i).ToString())
>
> Next
>
> Catch exp As Exception
>
> End Try
>
> End Sub
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
> Const SOCKET_ERROR = -1
>
> Const ICMP_ECHO = 8
>
> Dim RemoteIPs() As IPAddress
>
> Dim i As Integer
>
> ListBox1.Items.Clear()
>
> Dim RemoteHe As IPHostEntry
>
> Dim testHe As IPHostEntry
>
> Dim nBytes As Integer
>
> Dim dwStart As Integer
>
> Dim dwStop As Integer
>
> Dim TargetIPEP As IPEndPoint
>
> Dim TargetEP As EndPoint
>
> Dim s As Socket
>
> Dim li As System.Windows.Forms.ListViewItem
>
> Dim PacketSize As Integer
>
> Dim Packet As New IcmpPacket()
>
> Dim Index As Int32
>
> Dim PingData As Int32
>
>
>
> nBytes = 0
>
> dwStart = 0
>
> dwStop = 0
>
> PacketSize = 0
>
> s = New Socket(AddressFamily.InterNetwork, SocketType.Raw,
> ProtocolType.Icmp)
>
> s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout,
> 1000)
>
> RemoteHe = Dns.GetHostByName(TextBox4.Text)
>
> RemoteIPs = RemoteHe.AddressList
>
> For i = 0 To RemoteIPs.Length - 1
>
> li = ListView1.Items.Add(RemoteIPs(i).ToString())
>
> Next
>
> TargetIPEP = New IPEndPoint(RemoteIPs(0), 0)
>
> TargetEP = (TargetIPEP)
>
> Packet.Type = ICMP_ECHO
>
> Packet.SubCode = 0
>
> Packet.CheckSum = UInt16.Parse("0")
>
> Packet.Identifier = UInt16.Parse("45")
>
> Packet.SequenceNumber = UInt16.Parse("0")
>
> PingData = 32
>
> ReDim Packet.Data(PingData)
>
> 'Initilize the Packet.Data
>
> i = 0
>
> For i = 0 To PingData - 1
>
> Packet.Data(i) = System.Convert.ToByte(Chr(35))
>
> Next
>
> PacketSize = PingData + 8
>
> Dim icmp_pkt_buffer(PacketSize - 1) As Byte
>
> Index = 0
>
> Index = Serialize(Packet, icmp_pkt_buffer, PacketSize, PingData)
>
> If Index = -1 Then
>
> Console.WriteLine("Error in Making Packet")
>
> Exit Sub
>
> End If
>
> Dim double_length As Double
>
> double_length = Convert.ToDouble(Index)
>
> Dim dtemp As Double
>
> dtemp = System.Math.Ceiling(double_length / 2)
>
> Dim icmp_header_buffer_index As Integer
>
> icmp_header_buffer_index = 0
>
> Dim cksum_buffer_length As Integer
>
> Dim cksum_buffer() As UInt16
>
> cksum_buffer_length = Convert.ToInt32(dtemp)
>
> ReDim cksum_buffer(cksum_buffer_length)
>
> For i = 0 To cksum_buffer_length - 1
>
> cksum_buffer(i) = BitConverter.ToUInt16(icmp_pkt_buffer,
> icmp_header_buffer_index)
>
> icmp_header_buffer_index += 2
>
> Next
>
> Dim MyBuffer As UInt16()
>
> MyBuffer = cksum_buffer
>
> Dim u_cksum As UInt16
>
> u_cksum = checksum(MyBuffer, cksum_buffer_length)
>
> Packet.CheckSum = System.Convert.ToUInt16(52632)
>
> 'Now that we have the checksum, serialize the packet again
>
> Dim sendbuf() As Byte
>
> ReDim sendbuf(PacketSize)
>
> Index = Serialize(Packet, sendbuf, PacketSize, PingData)
>
> dwStart = System.Environment.TickCount ' Start timing
>
> If ((nBytes = s.SendTo(sendbuf, PacketSize, 0, TargetEP)) = SOCKET_ERROR)
> Then
>
> Console.WriteLine("Error calling sendto")
>
> Else
>
> Dim ReceiveBuffer(256) As Byte
>
> nBytes = 0
>
> nBytes = s.ReceiveFrom(ReceiveBuffer, 256, 0, TargetIPEP)
>
> If nBytes = SOCKET_ERROR Then
>
> dwStop = SOCKET_ERROR
>
> Else
>
> dwStop = System.Environment.TickCount - dwStart
>
> End If
>
> End If
>
> s.Close()
>
>
>
> End Sub
>
> Public Function Serialize(ByVal packet As IcmpPacket, ByRef Buffer As
> Byte(), ByVal PacketSize As Int32, ByVal PingData As Int32) As Int32
>
> Dim cbReturn As Int32
>
> Dim Index As Integer
>
> cbReturn = 0
>
> Index = 0
>
> Dim b_type(1) As Byte
>
> b_type(0) = (packet.Type)
>
> Dim b_code(1) As Byte
>
> b_code(0) = (packet.SubCode)
>
> Dim b_cksum As Byte()
>
> Dim b_id As Byte()
>
> Dim b_seq As Byte()
>
> b_cksum = BitConverter.GetBytes(packet.CheckSum)
>
> b_id = BitConverter.GetBytes(packet.Identifier)
>
> b_seq = BitConverter.GetBytes(packet.SequenceNumber)
>
>
>
> Array.Copy(b_type, 0, Buffer, Index, b_type.Length)
>
> Index += b_type.Length
>
> Array.Copy(b_code, 0, Buffer, Index, b_code.Length)
>
> Index += b_code.Length
>
> ' Console.WriteLine("Serialize cksum ");
>
> Array.Copy(b_cksum, 0, Buffer, Index, b_cksum.Length)
>
> Index += b_cksum.Length
>
> ' Console.WriteLine("Serialize id ")
>
> Array.Copy(b_id, 0, Buffer, Index, b_id.Length)
>
> Index += b_id.Length
>
> Array.Copy(b_seq, 0, Buffer, Index, b_seq.Length)
>
> Index += b_seq.Length
>
> ' copy the data
>
> Array.Copy(packet.Data, 0, Buffer, Index - 2, PingData)
>
> Index += PingData
>
> If Index - 2 <> PacketSize Then
>
> cbReturn = -1
>
> Serialize = cbReturn
>
> Exit Function
>
> End If
>
>
>
> Serialize = Index - 2
>
> End Function
>
> Public Function checksum(ByRef buffer As UInt16(), ByRef size As Integer) As
> UInt16
>
>
>
> End Function
>
> End Class
>
> HTH
> "gayxq" <ga...@163.net> wrote in message
> news:uNmjXwnfCHA.2092@tkmsftngp12...
> > This is a C# sample for 'Ping', Can anyone help me to convert to VB.Net.
> >
> >
> >
>
>
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
Imports System
Imports System.Runtime.InteropServices
Imports System.Net
Imports System.Net.Sockets
Public Class Form1
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
If disposing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ComponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.StatusBar1 = New System.Windows.Forms.StatusBar()
Me.Label1 = New System.Windows.Forms.Label()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.Label3 = New System.Windows.Forms.Label()
Me.TextBox4 = New System.Windows.Forms.TextBox()
Me.Label4 = New System.Windows.Forms.Label()
Me.Button2 = New System.Windows.Forms.Button()
Me.ListBox1 = New System.Windows.Forms.ListBox()
Me.ListBox2 = New System.Windows.Forms.ListBox()
Me.ListView1 = New System.Windows.Forms.ListView()
Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader()
Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader()
Me.SuspendLayout()
'
'StatusBar1
'
Me.StatusBar1.Name = "StatusBar1"
Me.StatusBar1.TabIndex = 0
Me.StatusBar1.Text = "StatusBar1"
'
'Label1
'
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 2
Me.Label1.Text = "Machine Name:"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'TextBox1
'
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
'
'Label2
'
Me.Label2.Name = "Label2"
Me.Label2.TabIndex = 4
Me.Label2.Text = "Local IP"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Button1
'
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 6
Me.Button1.Text = "Ping"
'
'Label3
'
Me.Label3.Name = "Label3"
Me.Label3.TabIndex = 9
Me.Label3.Text = "Local IP"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'TextBox4
'
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.TabIndex = 8
Me.TextBox4.Text = ""
'
'Label4
'
Me.Label4.Name = "Label4"
Me.Label4.TabIndex = 7
Me.Label4.Text = "Machine Name:"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Button2
'
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 11
Me.Button2.Text = "Resolve IP"
'
'ListBox1
'
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.TabIndex = 12
'
'ListBox2
'
Me.ListBox2.Name = "ListBox2"
Me.ListBox2.TabIndex = 13
'
'ListView1
'
Me.ListView1.GridLines = True
Me.ListView1.Name = "ListView1"
Me.ListView1.TabIndex = 14
Me.ListView1.View = System.Windows.Forms.View.Details
'
'ColumnHeader1
'
Me.ColumnHeader1.Text = "IP Address"
Me.ColumnHeader1.Width = 78
'
'ColumnHeader2
'
Me.ColumnHeader2.Text = "Address Family"
Me.ColumnHeader2.Width = 149
'
'Form1
'
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Public Class IcmpPacket
Public Data As Byte()
End Class
Dim str(20) As Byte
Dim len(1) As Int32
Dim iret As Long
len(0) = 20
Dim pstr As String
Dim lcldnslst As IPHostEntry
Dim lclIp() As IPAddress
Dim i As Integer
iret = GetComputerName(str, len)
TextBox1.Text = System.Text.Encoding.ASCII.GetString(str)
lcldnslst = Dns.GetHostByName(TextBox1.Text)
lclIp = lcldnslst.AddressList
ListBox2.Items.Add(lclIp(i).ToString())
Next
End Sub
End Sub
Dim lcldnslst As IPHostEntry
Dim lclIp() As IPAddress
Dim i As Integer
ListBox1.Items.Clear()
Try
lcldnslst = Dns.GetHostByName(TextBox4.Text)
lclIp = lcldnslst.AddressList
ListBox1.Items.Add(lclIp(i).ToString())
Next
Catch exp As Exception
End Try
End Sub
Const SOCKET_ERROR = -1
Const ICMP_ECHO = 8
Dim RemoteIPs() As IPAddress
Dim i As Integer
ListBox1.Items.Clear()
Dim RemoteHe As IPHostEntry
Dim testHe As IPHostEntry
Dim nBytes As Integer
Dim dwStart As Integer
Dim dwStop As Integer
Dim TargetIPEP As IPEndPoint
Dim TargetEP As EndPoint
Dim s As Socket
Dim li As System.Windows.Forms.ListViewItem
Dim PacketSize As Integer
Dim Index As Int32
Dim PingData As Int32
nBytes = 0
dwStart = 0
dwStop = 0
PacketSize = 0
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout,
1000)
RemoteHe = Dns.GetHostByName(TextBox4.Text)
RemoteIPs = RemoteHe.AddressList
li = ListView1.Items.Add(RemoteIPs(i).ToString())
Next
TargetEP = (TargetIPEP)
Packet.Type = ICMP_ECHO
Packet.SubCode = 0
PingData = 32
ReDim Packet.Data(PingData)
'Initilize the Packet.Data
i = 0
Packet.Data(i) = System.Convert.ToByte(Chr(35))
Next
Index = 0
Exit Sub
End If
Dim double_length As Double
double_length = Convert.ToDouble(Index)
Dim dtemp As Double
Dim icmp_header_buffer_index As Integer
icmp_header_buffer_index = 0
Dim cksum_buffer_length As Integer
Dim cksum_buffer() As UInt16
cksum_buffer_length = Convert.ToInt32(dtemp)
ReDim cksum_buffer(cksum_buffer_length)
cksum_buffer(i) = BitConverter.ToUInt16(icmp_pkt_buffer,
icmp_header_buffer_index)
icmp_header_buffer_index += 2
Next
Dim MyBuffer As UInt16()
MyBuffer = cksum_buffer
Dim u_cksum As UInt16
u_cksum = checksum(MyBuffer, cksum_buffer_length)
Packet.CheckSum = System.Convert.ToUInt16(52632)
Dim sendbuf() As Byte
ReDim sendbuf(PacketSize)
Else
Dim ReceiveBuffer(256) As Byte
nBytes = 0
dwStop = SOCKET_ERROR
Else
End If
End If
s.Close()
End Sub
Dim cbReturn As Int32
Dim Index As Integer
cbReturn = 0
Index = 0
Dim b_type(1) As Byte
b_type(0) = (packet.Type)
Dim b_code(1) As Byte
b_code(0) = (packet.SubCode)
Dim b_cksum As Byte()
Dim b_id As Byte()
Dim b_seq As Byte()
b_cksum = BitConverter.GetBytes(packet.CheckSum)
b_id = BitConverter.GetBytes(packet.Identifier)
b_seq = BitConverter.GetBytes(packet.SequenceNumber)
Index += b_type.Length
Index += b_code.Length
' Console.WriteLine("Serialize cksum ");
Index += b_cksum.Length
' Console.WriteLine("Serialize id ")
Index += b_id.Length
Index += b_seq.Length
' copy the data
Index += PingData
cbReturn = -1
Serialize = cbReturn
Exit Function
End If
End Function
End Function
End Class
HTH
You may also have a problem with
Me.ListView1.Columns.AddRange( _
New System.Windows.Forms.ColumnHeader _
( {Me.ColumnHeader1, Me.ColumnHeader2})
This looks like a shortcut to enter a list of array items, but I could not
find documentation on it or make it work so I just changed it to this:
Dim ch(1) As ColumnHeader
ch(0) = Me.ColumnHeader1
ch(1) = Me.ColumnHeader2
Me.ListView1.Columns.AddRange(ch)
HTH,
Bob
"Smoke" <sm...@netgate.com.uy> wrote in message
news:u$MsVbofCHA.1692@tkmsftngp09...
I believe it was a mid routine, but I wrote it about 6 months ago. Sorry.
"Smoke" <sm...@netgate.com.uy> wrote in message
news:u$MsVbofCHA.1692@tkmsftngp09...