Good Example for bi-directional Communication between Python and Windows (C#)

Hi,

Does anyone know where I can find a good example of duplex pipe communication between a process running Python and another running .NET (C#)? I am trying to do this with win32pipe. The documentation on this leaves much to be desired.

I found this example:

However, it only does a one-way operation, sending data from the server to the client.

Can anyone show me how to modify (augment) the code so that an object is sent from the client to the server, which does something to modify the object, then send it back to the client? Do I need to create another pipe to send data from the client to the server?

Any assistance with this would be appreciated.

1 Like

Does anyone know where I can find a good example of duplex pipe
communication between a process running Python and another running .NET
(C#)? I am trying to do this with win32pipe. The documentation on this
leaves much to be desired.

I found this example:
https://github.com/PeiSeng/Named_Pipe_Communication

Did you read the article to which it links, at:

https://medium.com/datadriveninvestor/named-pipes-communication-between-python-server-and-python-client-on-window-8cdf64504801

However, it only does a one-way operation, sending data from the server to the client.

Can anyone show me how to modify (augment) the code so that an object
is sent from the client to the server, which does something to modify
the object, then send it back to the client? Do I need to create
another pipe to send data from the client to the server?

Disclaimer: I am not a Windows person.

Looking at the code, the pipe seems to be set up to send in only one
direction (write in the client, read in the server). So in that case you
will need a second pipe set up the other way around: have the server
write the result to the client via the second pipe when done.

It may be that you can set these up in a bidirectional way - that would
be more normal. That depends on exactly what semantics a Windows pipe
provides: it needs to be like a network “connection” in that it actually
provides 2 data streams: one to send and one to receive. The you can
send your request and receive a result. On the server side you receive
the request and send the result.

In UNIX, pipes are not like that - you need 2 to do this kind of
comunication, and there is a distinct thing called a socket which
provides 2 channels (for send and receive). So you need to check what
kind of thing a Windows pipe is.

Cheers,
Cameron Simpson cs@cskk.id.au

1 Like

I did indeed read the article.

I suppose I was correct in speculating that I would require two pipes.

Thanks for the confirmation.

I don’t see any way to give you an upvote, or mark your post as being the correct answer, so please excuse me if I’ve overlooked something.

1 Like

It does not require two pipes. The article example actually sets up a two-way pipe, that’s what PIPE_ACCESS_DUPLEX specifies. The same handle works for both reading and writing, using ReadFile and WriteFile.

1 Like