SNMP and udpClient

G

Guest

Hi,

I am trying to build a SNMP application using VB .NET. I am using the
udpClient class to send and receive data.

The SNMP header when viewed in hex looks like :: 7E 05 13 C1 ........ 7E

My problem is the following. Udpclient's send method requires a byte array.

So I tried

Dim MyByte = ASCII.GetBytes(strPDU)
udpClient.Send(MyByte, MyByte.Length, sRemoteHost, sRemotePort)

However on the receiving end instead of getting (shown as hex) 7E 05 13 C!,

I get 7E 05 13 3F.

Now I understand that ascii support is only upto 127 and thats why this is
happening.

What is a better way of accomplishing this? I have tried looking at
udpClient samples in the documentation and on the web but they all use
ASCII.GetBytes method.

Thanks in advance

Pete.
 
G

Guest

Never mind,

I figured it out. Here's what I did ::
Dim win As Encoding = System.Text.Encoding.GetEncoding(1252)
Dim MyByte = win.GetBytes(sValue)
udpClient.Send(MyByte, MyByte.Length, sRemoteHost, sRemotePort)

This helped me get the windows code page encoding.

Pete.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top