Solved

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

Posted on 2008-09-30
8
286 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
  • 3
  • 3
  • 2
8 Comments
 
LVL 85

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 85

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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 85

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now