[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: shared memory access from within a Lua script..
- From: Gene Buckle <geneb@...>
- Date: Thu, 11 Mar 2004 12:32:15 -0800 (PST)
> >I am _very_ new to Lua (I'd never heard of it before today) and I find
> >myself needing to write a Lua script for a project I'm working on.
>
> Welcome!
>
Thanks!
> >I need to be able to move a fairly large amount of data from within a Lua
> >script to the "outside" world where I can deal with it using another
> >program. The only way I know to do this is by constructing a shared
> >memory segment.
>
> If I understand you correctly, all you need to do is to export a C function
> to Lua that writes to the shared memory segment. You'll need to work in C
> to setup this shared memory segment. The C function exported to Lua would
> get a Lua string and an offset into the shared memory segment and simply
> copy the Lua string to that position. Note that Lua string can hold arbitrary
> binary data.
>
Yep, this pretty much sums up what I need to do. Unfortunately, I suck at
C. I have a fairly good handle on what code on the C end I need to call
to support the shared memory segment (CreateFileMapping() ,etc), but I
have zero clue as to how to accomplish this. I don't even know if it's
possiblee to call the Win32 API from winthin a library that's not linked
to a "main()" of some kind. This is one of those things where I basically
need a lot of hand holding. :(
I'd like to be able to use sockets as an either/or option, but since it's
not built into Lua by default, I can't guarantee that it'll be available
in the product I have to interface to.
Am I correct in assuming that it's possible to cast the Lua string into a
struct on the side? Would I have to use a table for this instead?
Thanks!
g.