

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
7 messages in net.java.dev.jna.usersRe: [jna-users] Mapping posix message...| From | Sent On | Attachments |
|---|---|---|
| Patrick Schäfer | May 8, 2009 3:53 am | |
| Timothy Wall | May 8, 2009 4:02 am | |
| Patrick Schäfer | May 8, 2009 4:50 am | |
| Daniel Kaufmann | May 8, 2009 5:35 am | |
| Timothy Wall | May 8, 2009 5:37 am | |
| Patrick Schäfer | May 8, 2009 6:35 am | |
| Timothy Wall | May 8, 2009 6:55 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] Mapping posix message queue in C to Java | Actions... |
|---|---|---|
| From: | Patrick Schäfer (ps...@ekse.de) | |
| Date: | May 8, 2009 4:50:58 am | |
| List: | net.java.dev.jna.users | |
According to the man page, you need to look at the value of errno (Native.getLastError()) to determine the reason for failure if the call returns -1.
thank you for your response. Native.getLastError results in error code 22 which is "Invalid argument". I guess this means the jna mapping is incorrect?
I suppose this is due to the second argument "void *msgp"? According to the documentation void* should map to Pointer like this: int msgsnd(int msqid,Pointer msgp, int msgsz, int msgflg);
But how to instantiate a pointer? all constructors seem to be package- private.
On May 8, 2009, at 6:53 AM, Patrick Schäfer wrote:
Hi,
I am sry, but I am new to JNA.
I am trying to make a mapping for posix message queues in C (sys/ msg) to Java on my unix pc. but seem to be doing something completely wrong. Maybe anyone can help me with this?
Original C declaration int msgsnd(int msqid, const void *msgp, size_t msgsz,int msgflg); int msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp,int msgflg); int msgctl(int msqid, int cmd, struct msqid_ds *buf )
My equivalent JNA mapping int msgsnd(int msqid, byte[] msgp, int msgsz, int msgflg); int msgrcv(int msqid, byte[] msgp, int msgsz, NativeLong msgtyp, int msgflg); int msgctl(int msqid, int cmd, Structure buf );
Now I am not sure which library to load. Native.loadLibrary("sys/ msg", CLibrary.class) fails with an error.
The library "c" seems to have the function msgsnd, which I tested by Function test = NativeLibrary.getInstance("c").getFunction("msgrcv");
Therefor the library file is loaded by CLibrary INSTANCE = (CLibrary) Native.loadLibrary("c", CLibrary.class);
But trying to receive oder submit messages by int rc = CLibrary.INSTANCE.msgsnd( 0x0a0001c2, "test".getBytes(), 4, IPC_CREAT | 0666);
always results in the return code -1 without any exception or any other failure. is there a way to get further debug information?
thank you very much for any help.
Patrick







