Solved

vb.net -> Converting an Octet String into Byte?

Posted on 2004-04-11
3
1,935 Views
Last Modified: 2007-12-19
Hello everyone,

First a little background: I'm doing an SMPP client on vb.net, trying to communicate with my telco's SMSC. I've got the receiving part alright, but sending has got me stumped.

I have this hex value in String: "534D5050" ("SMPP"). I am currently writing it to my socket stream like this:


Dim w As New IO.StreamWriter(smppClient.GetStream)
w.Write("534D5050")
w.Flush()


Problem is, I need to send it as an octet, e.g. 53 is 00110101 in binary.

Hence, the actual data I have to send is, 00110101 1001101 1010000 1010000, but in *bytes*, not binary.

My question is, how do I go about converting hex strings into bytes?

edit: Just to clarify, using the example string "SMPP", I should send out 4 bytes instead of 8, like it is doing right now from my code above.


Thank you, and good day.
/Kev
0
Comment
Question by:orang_minyak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
tppradeep18 earned 500 total points
ID: 10804312
hi orang_minyak

There is a nice code available at the following URL which converts HEx to byte.

http://www.codeproject.com/csharp/hexencoding.asp

hope this helps

cheers

-----
pradeep
0
 

Author Comment

by:orang_minyak
ID: 10804676
Thank you. I'm looking into it now. Converting everthing into vb.net ;)
0
 

Author Comment

by:orang_minyak
ID: 10815031
Thanks! That helped alot.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question