Problem with sending hex in UDP packet

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.

Actually, the better question is:
How do I convert the array below to VB.NET? --

unsigned char grq[] = {
0x03, 0x20, 0x00, 0x00, 0x06, 0x00, 0x08, 0x91, 0x4a,
0x00,
0x02, 0x00, 0x0a, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8,
0x72,
0x04, 0x02, 0x01, 0x03, 0x85, 0x01, 0x40, 0x00, 0xc0,
0xa8,
0x0b, 0x16, 0xc0, 0x94, 0x02, 0x00, 0x01, 0x01, 0x80,
0x43,
0x36, 0x0c, 0x30, 0x02, 0x01, 0x10, 0x11,

0x02,
0x05, 0x2b, 0x0e, 0x03, 0x02, 0x06,
0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xfc, 0x0b, 0x01,
0x03
};
 
Back
Top