473,396 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with sending hex in UDP packet

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
Nov 20 '05 #1
1 3516
On Thu, 27 May 2004 16:36:49 GMT, spammersarevermin
<sp***************@krumpli.com> wrote:
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
};

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: coder_1024 | last post by:
I'm trying to send a packet of binary data to a UDP server. If I send a text string, it works fine. If I attempt to send binary data, it sends a UDP packet with 0 bytes of data (just the...
4
by: vertigo | last post by:
Hello I have: struct packet{ byte type; /*my byte is unsigned char*/ int len; } struct packet *p = new struct packet; p->type=10; p->len=0;
5
by: Terry | last post by:
It's my understanding of UDP sockets that if there is a thread blocked on a "recvFrom()" call and other thread sends a UDP packet to some address, that if the machine on the other end isn't up,...
2
by: Fernando Barsoba | last post by:
Dear all, I have been posting about a problem trying to encrypt certain data using HMAC-SHA1 functions. I posted that my problem was solved, but unfortunately, I was being overly optimistic. I...
4
by: Abubakar | last post by:
Hi, I am writing a server in C# and client in C++ (pure, not managed). The communication goes on through sockets. In C# I am using NetworkStream to send text data (by converting it to byte array)...
10
by: PH | last post by:
Hi guys! I need to get the remote EndPoint from when I receive packets when listening in a local port in my computer. I'm using UDP (connection-less) so I only bind the socket to my...
9
by: darthghandi | last post by:
I am trying to create a server application using asynchronous sockets. I run into a problem when I try to connect to my server using a non-.net program. I can establish the connection, and send...
6
by: White Spirit | last post by:
I have the following code to send a packet to a remote socket and receive a response in return: System.Net.Sockets.Socket locSocket = new System.Net.Sockets.Socket (AddressFamily.InterNetwork,...
11
by: Krzysztof Retel | last post by:
Hi guys, I am struggling writing fast UDP server. It has to handle around 10000 UDP packets per second. I started building that with non blocking socket and threads. Unfortunately my approach...
1
by: Jean-Paul Calderone | last post by:
On Fri, 21 Nov 2008 00:20:49 -0200, Gabriel Genellina <gagsl-py2@yahoo.com.arwrote: If you want to try this program out on POSIX, make sure you change the time.clock() calls to time.time() calls...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.