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.
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.