Forum > Unix
msgrcv only succeeds if msgsnd sends a buffer with only zeros.
TCH:
I use no library and i open no socket. The OS is Linux AMD64, the target is the same. The FPC is of version 3.2.2 The C and Pascal code are here:
http://oscomp.hu/depot/msgtest.c
http://oscomp.hu/depot/msgtest.pas
And i've read the manual; the C code works as intended. But in the Pascal code, only a longint of zero can be transmitted, all else will yield a result of -1 and ESysENOMSG in errno (fpgeterrno).
MarkMLl:
--- Quote from: TCH on May 18, 2022, 06:36:02 pm ---I use no library and i open no socket. The OS is Linux AMD64, the target is the same. The FPC is of version 3.2.2 The C and Pascal code are here:
http://oscomp.hu/depot/msgtest.c
http://oscomp.hu/depot/msgtest.pas
And i've read the manual; the C code works as intended. But in the Pascal code, only a longint of zero can be transmitted, all else will yield a result of -1 and ESysENOMSG in errno (fpgeterrno).
--- End quote ---
You are using the Pascal ipc library as documented at https://www.freepascal.org/docs-html/current/rtl/ipc/index-5.html.
I suggest you start off with the example give there, without making any assumptions that it is directly compatible with the low-level unix API.
MarkMLl
TCH:
Isn't that a unit? Also, even if it's not compatible with the UNIX API, why does it work with a buffer of zeros and not elseway? This is the most basic existing usage: one send and one receive. It should work.
Besides i need to be compatible with the UNIX API. The programs will not necessarily be all written in Pascal. Maybe either process will be C, the other will be Pascal. (Not this one example.)
Lutz Mändle:
Hi,
in your demo program change message type record to:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type mymsg_t = record mtype: clong; mtext: array[0..7] of byte;end;
Also change the line
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- msqid := msgget(IPC_PRIVATE, 0600 or IPC_CREAT);to
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- msqid := msgget(IPC_PRIVATE, &0600 or IPC_CREAT);
Then it works.
TCH:
Changing the type of mtype from longword to int64 did the trick, thank you very much!
You are right about the missing & character too, but that was only a mistake in the example code i provided here; in the actual code, the & was there to sign the octal representation: the erroneous type caused the problem.
I don't get this though. These functions are calling the libc functions, aren't they? (At least according to packages/rtl-extra/src/unix/ipc.pp:656, or FPC_USE_LIBC is not set?) The needed structure should be identical and the C versions use 32-bit for that field everywhere...
Navigation
[0] Message Index
[#] Next page
[*] Previous page