Recent

Author Topic: Wine and Linux interoperability  (Read 4486 times)

devEric69

  • Hero Member
  • *****
  • Posts: 648
Wine and Linux interoperability
« on: September 10, 2020, 05:39:56 pm »
Hello (may be a stupid question),

Is it possible to make communicate with each other, a compiled IPC client for Windows (Wine, in fact) and a compiled IPC server under Linux, or vice versa ( it's almost the same question as this post: https://forum.lazarus.freepascal.org/index.php/topic,51316.0.html, but in a different context i.e. i'm thinking of one program that runs under Wine, while another program runs under Linux)?
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: Wine and Linux interoperability
« Reply #1 on: September 10, 2020, 06:06:25 pm »
I can't speak for FPC's IPC library. Standard Internet-domain TCP or UDP sockets will work, subject to the rule that without special handling a program running on a unix-like OS can't listen/bind to ports below 1024. I'd probably avoid trying unix-domain sockets, and I think I'd avoid "traditional" Windows pipes (named or otherwise, stream or datagram) since the impression I get is that things like that are rather at the mercy of changes of WINE and Windows API versions.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: Wine and Linux interoperability
« Reply #2 on: September 12, 2020, 11:42:17 am »
Hi,

Quote
I can't speak for FPC's IPC library.

I fact, i was thinking about FPC's IPC library.
But that seems not possible, with the FPC's IPC library, because:
- under Windows \ Wine, the communication is done by a TxxxMsgClientComm Class, with sendMessageof a WM_DATA structure, from the IPC client towards the handle returned by a FindWindow('NameOfServerIPC'), handle of a window having a standard loop (while Peekmessage...).
- under Linux, it's completely different: the exchange is done with a TxxxPipeClientComm Class, using a kind of shared file in memory (using TFileStream.Create(FFileName, ...)), via a call to the Linux API named mkfifo (@lias: fpmkFifo). So, the technique used under Linux is a regular named file used as a "named pipe".

Quote
Standard Internet-domain TCP or UDP sockets will work, subject to the rule that without special handling a program running on a unix-like OS can't listen/bind to ports below 1024. I'd probably avoid trying unix-domain sockets.

Maybe, the simplest could be the use of Standard Internet-domain TCP or UDP sockets, with the common networking address 127.0.0.1 (i didn't know what Unix domain socket was: i've just read on Wikipedia, what they are used for).

I've looked at other posts on this forum (Lazarus) and on the Wine forum: apparently, the real Linux technology for the IPC is D-Bus: the Wine users have made requests for development so that Wine could call D-Bus. But, at the moment, the two OSes do not have the same address space, don't know which lock has already been put on a common file by the other OS, and afaik, even an interruption of the Linux system from Wine is currently impossible. So, no communication at all.

Another simple method could be the use of simple text files (the hard disk is common to both OSes, without even having to install Samba, there; no need to make a "net use" from Wine), more seen in a producer \ consumer blocks of [KBytes] information's paradigm, than in a server \ client IPC point of view, or even get help from the system timer (common to both OSes too).
« Last Edit: September 12, 2020, 01:29:05 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: Wine and Linux interoperability
« Reply #3 on: September 12, 2020, 11:57:47 am »
A unix domain socket is like a UDP datagram socket (I can't remember whether it can also be used for streams) but is local rather than networked. I can't speak for what higher-level abstractions FPC etc. offers, but if you've used UDP they're a no-brainer subject to (a) being created by name rather than by port number and (b) if you're running non-root then

* If you want to use a TCP or UDP port < 1024 (can't remember whether that's < or <=) you need the POSIX NET_BIND_SERVICE capability.

* If you want to put a unix domain socket in a privileged directory such as /var/run then you need the POSIX CAP_DAC_OVERRIDE capability.

In both cases, once you've created the socket you can- in fact are encouraged to- relinquish the capability.

If you're using a port >1024 or are putting the named socket in ~ or /tmp then you don't need any special capabilities.

It might be worth exploring whether a program running under WINE has sufficient native API access to be able to use unix domain sockets, since it could be a useful addition to FPC's IPC library.

MarkMLl



MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: Wine and Linux interoperability
« Reply #4 on: September 12, 2020, 12:10:33 pm »
Ok, thanks for these explanations, about the use of a Unix domain socket.
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

 

TinyPortal © 2005-2018