G
Guest
I'm trying to put some hex values in a UDP packet & I don't have a
clue how to accomplish this. Using the code below results in a packet
going out w/ the right buffer length but all 00's as the data payload.
Any help is appreciated. Sorry for the wrap.
Thanks
Public Function SendData() As IAsyncResult
Try
' Get remote host IP address or hostname
Dim re_port As Integer = 1719 ' port 1719 for RAS
Dim udpClient As New UdpClient
Dim epremote As New IPEndPoint _
(IPAddress.Parse(TextBox1.Text), re_port)
Dim timeout As Integer = CInt(TextBox3.Text)
Dim i As Integer
Dim sendbuffer As [Byte]() = {&H30, &H20, &H0, &H0, &H60,
&H0, _
&H80, &H91, &H4A, &H00, &H20, &H0, &HA, &H60, &H86, &H48, &H1, _
&H86, &HF8, &H72, &H40, &H20, &H10, &H30, &H85, &H10, &H40, &H0, _
&HC0, &HA8, &HB, &H16, &HC0, &H94, &H20, &H0, &H10, &H10, &H80, _
&H43, &H36, &HC0, &H30, &H20, &H10, &H10, &H11, &H20, &H50, &H2B,
_
&HE, &H30, &H20, &H60, &H90, &H60, &H86, &H48, &H10, &H86, &HFC, _
&HB, &H10, &H30}
' Send routine starts here ***********************
Done = False
While Not Done
' Send a message to new UdpClient (epremote)
i += 1
udpClient.Send(sendbuffer, sendbuffer.Length,
epremote)
ListBox1.Items.Add("Packet #" & i & " sent" & " " &
sendbuffer.Length)
' Clear sendbuffer
sendbuffer.Clear(sendbuffer, 0, sendbuffer.Length)
System.Threading.Thread.Sleep(timeout)
End While
' Send routine ends here ***************************
Return ar
udpClient.Close()
Catch ex As System.Net.Sockets.SocketException
MsgBox("Exception: {0}" + ex.ToString)
End Try
End Function
clue how to accomplish this. Using the code below results in a packet
going out w/ the right buffer length but all 00's as the data payload.
Any help is appreciated. Sorry for the wrap.
Thanks
Public Function SendData() As IAsyncResult
Try
' Get remote host IP address or hostname
Dim re_port As Integer = 1719 ' port 1719 for RAS
Dim udpClient As New UdpClient
Dim epremote As New IPEndPoint _
(IPAddress.Parse(TextBox1.Text), re_port)
Dim timeout As Integer = CInt(TextBox3.Text)
Dim i As Integer
Dim sendbuffer As [Byte]() = {&H30, &H20, &H0, &H0, &H60,
&H0, _
&H80, &H91, &H4A, &H00, &H20, &H0, &HA, &H60, &H86, &H48, &H1, _
&H86, &HF8, &H72, &H40, &H20, &H10, &H30, &H85, &H10, &H40, &H0, _
&HC0, &HA8, &HB, &H16, &HC0, &H94, &H20, &H0, &H10, &H10, &H80, _
&H43, &H36, &HC0, &H30, &H20, &H10, &H10, &H11, &H20, &H50, &H2B,
_
&HE, &H30, &H20, &H60, &H90, &H60, &H86, &H48, &H10, &H86, &HFC, _
&HB, &H10, &H30}
' Send routine starts here ***********************
Done = False
While Not Done
' Send a message to new UdpClient (epremote)
i += 1
udpClient.Send(sendbuffer, sendbuffer.Length,
epremote)
ListBox1.Items.Add("Packet #" & i & " sent" & " " &
sendbuffer.Length)
' Clear sendbuffer
sendbuffer.Clear(sendbuffer, 0, sendbuffer.Length)
System.Threading.Thread.Sleep(timeout)
End While
' Send routine ends here ***************************
Return ar
udpClient.Close()
Catch ex As System.Net.Sockets.SocketException
MsgBox("Exception: {0}" + ex.ToString)
End Try
End Function