Skip to content Skip to sidebar Skip to footer

Simplest Way To Communicate Between Python And C# Using Ipc?

I have some C# code that needs to call a Python script several thousand times, each time passing a string, and then expecting a float back. The python script can be run using ANY v

Solution 1:

Use zeromq.

  • allows very light messaging without a need for broker
  • is available for many platforms
  • can communicate over TCP socket, unix socket or inside a process

Here is my answer using zeromq https://stackoverflow.com/a/23227631/346478

It serves for messaging between different Python programs, but exactly the same method of communication can be used between other platforms. Just keep the messages passed around interopable - both sides must understand the content properly. You can play with binary data, but very often json representation work quick and easy too. But there are many serialization frameworks like result buffers and others, which might help you to encode result.

Solution 2:

Based on the what you have said, you can connect to the python process and catch standard output text. Easy, fast and reliable!

Post a Comment for "Simplest Way To Communicate Between Python And C# Using Ipc?"