realbasic-nug
[Top] [All Lists]

Re: Turning Integers into MemoryBlocks?

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Turning Integers into MemoryBlocks?
From: Charlie Boisseau <charlie at 006 dot co dot uk>
Date: Tue, 31 Aug 2004 15:49:55 +0100
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <86BE5A62-FB59-11D8-9A45-000393C0FE92 at 006 dot co dot uk> <FF5157ED-FB5B-11D8-B23F-000A95880024 at bitjuggler dot com>
On 31 Aug 2004, at 15:42, Thomas Reed wrote:

What routine are you calling, and what does your code look like? I have a number of callback routines that are defined to return MemoryBlocks, and they work just fine. I'd be extremely surprised if you couldn't use MemoryBlock as a parameter type in a callback as well.

I looked at Jon's previous post as he suggested. I found that i was missing the line mb = mb.Ptr(0), but these make the MemoryBlock empty.

Here's my code. It's a callback for the libpcap packet capturing library, it fires when a packet is captured. Any Ideas?

Sub got_packet(Args As Integer, Header As Integer, Packet As Integer)
   Dim head As New MemoryBlock(1500)
   Dim pkt As New MemoryBlock(1500)

   Dim head_str, pkt_str As String

   head.long(0) = Header
   pkt.long(0) = Packet

   head = head.Ptr(0)
   pkt = pkt.Ptr(0)

   head_str = head.StringValue(0, head.Size)
   pkt_str = pkt.StringValue(0, pkt.Size)

   head_str = ReplaceAll(head_str, Chr(0), "")
   pkt_str = ReplaceAll(pkt_str, Chr(0), "")


   System.DebugLog "  Header: " + head_str + "  Packet: " + pkt_str

End Sub


--
Charlie Boisseau

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>