Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-09

IPC Question

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Weinert

Hi all,

I wrote 2 programs which are using the IPC queue. Now I have a problem, that often the the queue cannot be opened. I did some tests and cannot find out where the problem is. The relevant code is here:

  ipcqueue:='/var/ipc';
  IPC_Key:=ftok(ipcqueue,'M');			// Eindeutigen Schlüsssel generieren
  IPC_ID:=msgget(IPC_Key,IPC_CREAT or 438);	// Schnittstelle erstellen

No matter what I do with /var/ipc the IPC-Queue doesn't get created. I tried /var/ipc as file, directory and not existent, but nothing helps.

Does anybody here know the right procedure to open an ipc-queue. Thanks in advance for your help.

Michael.

SysQuadrat Michael Weinert Stuttgart Filderstadt-Plattenhardt Tel.: 0711-9970288 Fax: 5360559 Mobil: 0170-4141273 http://www.linux-firewall.de

Reply by email

L D Blake
to Michael Weinert

Hello,
This is in reply to your letter of September 3, 2003

Show quoted text 18 lines
Hi all, I wrote 2 programs which are using the IPC queue. Now I have a problem, that often the the queue cannot be opened. I did some tests and cannot find out where the problem is. The relevant code is here: ipcqueue:='/var/ipc'; IPC_Key:=ftok(ipcqueue,'M'); // Eindeutigen Schlüsssel generieren IPC_ID:=msgget(IPC_Key,IPC_CREAT or 438); // Schnittstelle erstellen No matter what I do with /var/ipc the IPC-Queue doesn't get created. I tried /var/ipc as file, directory and not existent, but nothing helps. Does anybody here know the right procedure to open an ipc-queue. Thanks in advance for your help. Michael.

When I first started with FP I ran into a bunch of really strange behaviour. Files that wouldn't open, garbage printed in edit boxes, things being saved under garbled filenames etc.

In my case, which may or may not apply to what you are doing here, the problem was the difference between the way Pascal and Windows handle strings. In pascal a string is like this:

<Length Byte><string data....>

In windows (and I think Linux) it's like this:

<string data....><0>

If 'ipcqueue' is declared as type "string" could it be that your OS is seeing the length byte as an error and failing to open the queue? (At least that's what happened to me in win32).

The fix, for me, was to write a small unit to translate back and forth between Pascal and Null Terminated strings.

Best regards, L D Blake

Reply by email