Sign in Join

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

Mailing lists / fpc-pascal / 2016-10

Piping: high level tool? Strong types sent via pipe

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Lars

I was thinking: pipes are useful to communicate between processes. How about a high level communication system instead of just sending low level strings over the pipe? For example strong typing. If you want to send an integer over a pipe, you generally have to parse the string and ensure it is a number being sent over the pipe and not text, etc. So instead of everyone reinventing their own strong typing system over pipes to ensure data is received correctly, why not have a pipe library that anyone can use which sends strongly typed information over the pipe?

i.e. Pipe.SendInteger, Pipe.SendString,

Instead of just

writeln(pipe, 'a string') which will need to be parsed and checked.

This may be something like interprocess communication library that is already available for FPC, I don't know. I just had a brainstorm here... pipes remind me of sockets...if you send data over a socket you have to parse it, deal with it... Everyone reinvents their own messaging system instead of having a single high level tool that everyone uses.

Also nice would be:

Pipe.Send(varargs)

i.e.

Pipe.Send(integer, string, byte, anythingyouwant).

Am I just reinventing the library already available for fpc for IPC (interprocess communication) ?

Last time I tried it (been a long time) I had some issues with duplicates showing up when communicating over IPC.

Anyway so what I would like to do, is have one process open up a pipe, and send strongly typed data to another process. This is almost as powerful as having a DLL since a dll allows you to communicate code between a dll and an exe.. But with pipes no DLL is required, just two exes. This is extremely powerful underused mechanism to create exe or elf plugins that communicate with a main exe/elf program.

I don't like low level piping and sockets where you have to parse data and create your own message system: everyone reinvents the wheel instead of having a single library to use that is high level. I think sockets communication and pipes are the biggest case of everyone reinventing the wheel that there is!

Reply by email

Jonas Maebe
to Lars
Lars wrote
Am I just reinventing the library already available for fpc for IPC (interprocess communication) ?

The simpleipc unit does not contain support for sending arbitrarily typed data, but you could use the fcl-json units to encode your data in json, send the json data as a string, and decode it again on the other side.

You could also build a wrapper unit on top of that.

Jonas

Reply by email