Solved

UDP_listener, how to display a hex string on the Data_Arrived event.

Posted on 2008-09-30
8
298 Views
Last Modified: 2013-12-26
I'm using a simple example like this to receive incoming ascii but when
I'm receiving a hex dump, nothing displays.

Private Sub Form_Load()
server.LocalPort = 5890
server.Bind Winsock1.LocalPort
End Sub

Private Sub server_DataArrival(ByVal bytesTotal As Long)
Dim mydata As String
server.GetData mydata

Text1 = Text1 & mydata & vbCrLf
End Sub


I think it has something to do with this part of the code
Private Sub server_DataArrival(ByVal bytesTotal As Long)

Any help would be appreciated.



0
Comment
Question by:Bward323
[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
  • 3
  • 3
  • 2
8 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22614717
Try it this way instead:

    Private Sub server_DataArrival(ByVal bytesTotal As Long)
        Dim mydata As String
        server.GetData mydata, vbString
        Text1.Text = Text1.Text & mydata & vbCrLf
    End Sub

0
 

Author Comment

by:Bward323
ID: 22615322
for some reason I'm not getting anything. I added this line just to see when the event fires

msgbox "event fired " & mydata

and all I am getting in the msgbox is "event fir4ed"
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22615631
=\

Are you getting a value in "bytesTotal"?

 Private Sub server_DataArrival(ByVal bytesTotal As Long)
        Dim mydata As String
        server.GetData mydata, vbString
        Debug.Print "DataArrival:"
        Debug.Print "bytesTotal = " & bytesTotal
        Debug.Print "mydata = " & mydata
    End Sub

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Bward323
ID: 22616518
Yes I am. The client is a GPRS device that I have send a test message....   "12345"
It sends this via UDP as a Hex Dump

The only thing I am seeing displayed on the screen is a message box that says,
 bytes total = 9
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22616593
I'm not sure what's going wrong...and obviously I can't test it from here.  =(

I would start trouble shooting by starting with a fresh project and only the BARE BONES minimum code to receive a simple message and Debug.Print or MsgBox it.  This way you can determine if something else in your current project is possibly interfering...

0
 
LVL 3

Expert Comment

by:moonlight
ID: 22669175
Thanks Idle Mind for showing me this thread. Bward323, I have exactly the same problem:

http://www.experts-exchange.com/Programming/Languages/Winsock/Q_23796509.html#a22668967
0
 

Author Comment

by:Bward323
ID: 22886329
I found that the reason I was seeing  a string length  but nothing was showing up was that iit was a hex string.. I used this routine to convert from hex to ascii
Text1.text = HexString(strData)


Private Function HexString(EvalString As String) As String
Dim intStrLen As Integer
Dim intLoop As Integer
Dim strHex As String

EvalString = Trim(EvalString)
intStrLen = Len(EvalString)
For intLoop = 1 To intStrLen
strHex = strHex & " " & Hex(Asc(Mid(EvalString, intLoop, 1)))
Next
HexString = strHex

End Function
0
 
LVL 3

Accepted Solution

by:
moonlight earned 125 total points
ID: 22887415
yes it turned out it was two different things eventhough the same symptom. Glad you solved it too.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

726 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