-6

Windows 10, .Net Core 3.1

How to do the processes communication on the same computer in .NET Core 3.1? I used WCF for these purposes when I used .NET Framwork earlier, but .NET Core hasn't WCF. I would not want to use the file system and FileSystemWatcher or write windows services for these purposes...

Andrey Bushman
  • 11,712
  • 17
  • 87
  • 182
  • 2
    Have you considered using gRPC? Anyways, that question is rather an opinion based so I think it'll be closed eventually. – Gleb Jan 17 '20 at 11:09
  • 2
    FSW has nothing to do with inter-process communication and WCF is primarily used for *SOAP* web services. What *do* you want to do? What protocol do you want to use? – Panagiotis Kanavos Jan 17 '20 at 11:10
  • 2
    @Gleb gRPC for *IPC*? – Panagiotis Kanavos Jan 17 '20 at 11:10
  • WCF was created as an umbrella API over multiple communication protocols. In reality, this only worked for SOAP. It was too cumbersome and heavy for all other cases. The *real* question is which protocol do you want to use? Once you decide that, you can look for libraries. – Panagiotis Kanavos Jan 17 '20 at 11:13
  • @PanagiotisKanavos I have couple simple console application. They are to comunicate in runtime. – Andrey Bushman Jan 17 '20 at 11:15
  • You can use shared memory through memory mapped files. That's the fastest way. You can go from low level sockets, TCP, [Named pipes](https://learn.microsoft.com/en-us/dotnet/standard/io/how-to-use-named-pipes-for-network-interprocess-communication) (which were also available through WCF). – Panagiotis Kanavos Jan 17 '20 at 11:16
  • @AndreyBushman communicate *how*? In the simplest case, you could just pipe them together. WCF was the API, not the mechanism. Even if you decided to use WCF you'd have to pick the mechanims. WCF offered TCP, Named Pipes, HTTP, MSMQ and you could add even more with custom bindings. – Panagiotis Kanavos Jan 17 '20 at 11:18
  • @AndreyBushman that doesn't explain anything - almost all applications work that way and some use multiple protocols. For example, SQL Server offers mapped memory, named pipes and TCP. The *clipboard* is another IPC mechanism. DDE. Mailslots. COM allows one application to talk to another. That's how Office Interop works. – Panagiotis Kanavos Jan 17 '20 at 11:21
  • I would use REST. gRPC looks interesting, but REST is much more widely used. – Hans Kilian Jan 17 '20 at 11:22
  • What are the actual requirements? Speed, security, convenience, developer familiarity? – Panagiotis Kanavos Jan 17 '20 at 11:22
  • @PanagiotisKanavos thank you, I will try to use the named pipes. – Andrey Bushman Jan 17 '20 at 11:23
  • 1
    @HansKilian except there's no thing as REST, it's a style that works over HTTP which is actually a specific format over HTTP. And a lot heavier than eg memory sharing – Panagiotis Kanavos Jan 17 '20 at 11:23
  • @PanagiotisKanavos I try to find the decission for my problem I described here: https://stackoverflow.com/questions/59770445/how-to-use-the-individual-console-windows-for-the-child-console-applications . – Andrey Bushman Jan 17 '20 at 11:24
  • @AndreyBushman that question has nothing to do with IPC, it's only about *terminals*, which don't work that way. The `Process` object gives you access to the new process's input, output and error streams, so you may not need another IPC mechanism – Panagiotis Kanavos Jan 17 '20 at 11:28
  • We use WCF extensively for communications between C# processes. We've decided to switch to [gRPC (protobuf)](https://grpc.io/) when we rewrite code for .Net Core. There are [NuGet packages to help with this](https://www.nuget.org/packages/Google.Protobuf/). – Matthew Watson Jan 17 '20 at 11:30
  • You can follow this article - https://visualstudiomagazine.com/articles/2019/06/10/net-core-open-source.aspx – Rameshwar Trivedi Jan 17 '20 at 11:41
  • @MatthewWatson the original question asks how to use multiple terminals for output – Panagiotis Kanavos Jan 17 '20 at 11:43
  • note: if you *are* interested in gRPC, but you like the WCF coding style: protobuf-net.Grpc has you covered (it utilizes the Google/Microsoft stacks internally - it just changes the API surface): [Getting Started](https://protobuf-net.github.io/protobuf-net.Grpc/gettingstarted) – Marc Gravell Jan 17 '20 at 12:09
  • @mjwills Here is more detailed info what I try to do: https://stackoverflow.com/questions/59770445/how-to-use-the-individual-console-windows-for-the-child-console-applications – Andrey Bushman Jan 17 '20 at 12:32

1 Answers1

1

Currently gRPC is described as to be a way for wcf migration, you can communicate in half streaming, full streaming. But be careful that half streaming can interrupt to collect information but it will not interrupt all the process on the server side. From what i seen, on asp.net (there is a core version) the context. CancellationToken you will see on examples is called only when the client disconnect (closing by example), the most of time examples show how to interrupt reception from client, but if you launch an object by the grpc server with an infinite loop, it will continue to exist. It's important to make some tests before to really mastering this. In the other case the double streaming is here to help you, with a simple word you can stop the duplex properly.

You must identify your needs.

What else... the service used on asp.net with grpc launch a new object to each request, you must keep it in memory.

For the while i don't know how to transmit an unknown object, but for known objects you will definite "class" used in the proto files, generate your project, and vs2019 create files for you. Currently to add this service to an existing project you must edit your project, or you will have some problems to add protobuf (*.proto) files "Sdk="Microsoft.NET.Sdk.Web" is required.

I hope it helped you.

Vonkel.
  • 306
  • 3
  • 12