「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicrosofttech.osscons.jp/]]」は、「[[Open棟梁Project>https://github.com/OpenTouryoProject/]]」,「[[OSSコンソーシアム .NET開発基盤部会>https://www.osscons.jp/dotNetDevelopmentInfrastructure/]]」によって運営されています。

-[[戻る>その他、開発の色々]]

* 目次 [#ucb91276]
#contents

*概要 [#tf883ba7]
プロセス間通信について
プロセス間通信についてまとめた。

*詳細 [#d40d71c8]

**基本 [#w62e240d]
-共有メモリ、パイプ(名前付き/匿名)、UDP/TCPなどがある。
-子プロセスとの通信なら匿名パイプを使用すると良い。

***共有メモリ [#z4db4fcf]
内部的には、ページングファイルに支持されたメモリマップド・ファイルを使用する。

-内部的には、ページングファイルに支持されたメモリマップド・ファイルを使用する。
-実装については、下記の「[[SharedMem.xaml.cs>#ga1c6605]]」を参照のこと。~
ただし、[[Touryo.Infrastructure.Public.Util.SharedMemory>https://github.com/OpenTouryoProject/OpenTouryo/blob/develop/root/programs/CS/Frameworks/Infrastructure/Public/Util/SharedMemory.cs]]に依存している。
***パイプ [#t693fdb4]
-名前付きパイプ
--名前付きパイプを使用して、プロセス間通信を行う場合、~
パイプ・オブジェクトの始点と終端を2プロセス間で持つ。
--このとき、パイプ・オブジェクトをIDのようなもので~
識別するのが、名前付きパイプになる。

--従って、名前付きパイプの場合、~
2プロセスがパイプ名を共有している必要がある。

--詳細については、下記の「[[NdPipe.xaml.cs>#ga1c6605]]」を参照のこと。

-匿名パイプ
--一方、匿名パイプは、名前が無いので、名前で共有できない。
--その代りに、親側から、子側に、ハンドラを複製して渡す。
--その代りに、親プロセス側から、子プロセス側に、ハンドラを複製して渡す。~
(従って、匿名パイプは、親子プロセス間通信での利用が一般的になる)

--このハンドラの複製に、
---Windows OSでは、DuplicateHandle関数を使用し、
---Unix系OSでは、fork関数を使用する。

--.NETでは、このハンドラの複製に、~
--参考

---[ C言語 ] プロセスの生成 ( fork ) と パイプによる~
プロセス間通信 ( pipe ) – 行け!偏差値40プログラマー~
http://hensa40.cutegirl.jp/archives/1032
---親プロセス・子プロセス間通信 - Qiita~
https://qiita.com/SoyaTakahashi/items/f28d0b5ef404afd339fa

---.NETでは、このハンドラの複製に、~
https://github.com/OpenTouryoProject/SampleProgram/blob/master/Other/PipesFamilyHouse/AnonymousPipe/Parent/Program.cs#L77~
HandleInheritability.Inheritableを使用している。~
これは、内部(Win32)的に、DuplicateHandle関数と思われる。

-参考
--[ C言語 ] プロセスの生成 ( fork ) と パイプによる~
プロセス間通信 ( pipe ) – 行け!偏差値40プログラマー~
http://hensa40.cutegirl.jp/archives/1032

***UDP [#g9cdf481]
コネクションレス型の通信
-コネクションレス型の通信
-実装については、下記の「[[UDP.xaml.cs>#ga1c6605]]」を参照のこと。

***TCP [#e54d5a5e]
コネクション型の通信
-コネクション型の通信
-実装については、下記の「[[TCP.xaml.cs>#ga1c6605]]」を参照のこと。

**その他 [#z2424263]

***[[RPC]] [#c07b83ee]
-DCE/RPC
--DCOM
--.NET Remoting

-Webサービス
--XML-RPC
--JSON-RPC

-WCF (Windows Communication Foundation)

***[[ウィンドウ・システム]] > [[ウィンドウ メッセージ]] [#dbcee084]

*参考 [#v50a11dd]

**OpenTouryoProject/SampleProgram · GitHub [#offaeb4a]

-SampleProgram/Other/InterProcComm at master~
***InterProcComm at master [#ga1c6605]
https://github.com/OpenTouryoProject/SampleProgram/tree/master/Other/InterProcComm
--[[SharedMem.xaml.cs>https://github.com/OpenTouryoProject/SampleProgram/blob/master/Other/InterProcComm/SharedMem.xaml.cs]]
--[[NdPipe.xaml.cs>https://github.com/OpenTouryoProject/SampleProgram/blob/master/Other/InterProcComm/NdPipe.xaml.cs]]
--[[UDP.xaml.cs>https://github.com/OpenTouryoProject/SampleProgram/blob/master/Other/InterProcComm/UDP.xaml.cs]]
--[[TCP.xaml.cs>https://github.com/OpenTouryoProject/SampleProgram/blob/master/Other/InterProcComm/TCP.xaml.cs]]
-[[SharedMem.xaml.cs>https://github.com/OpenTouryoProject/SampleProgram/blob/master/Other/InterProcComm/SharedMem.xaml.cs]]
-[[NdPipe.xaml.cs>https://github.com/OpenTouryoProject/SampleProgram/blob/master/Other/InterProcComm/NdPipe.xaml.cs]]
-[[UDP.xaml.cs>https://github.com/OpenTouryoProject/SampleProgram/blob/master/Other/InterProcComm/UDP.xaml.cs]]
-[[TCP.xaml.cs>https://github.com/OpenTouryoProject/SampleProgram/blob/master/Other/InterProcComm/TCP.xaml.cs]]

-SampleProgram/Other/PipesFamilyHouse at master~
***PipesFamilyHouse at master [#vef413e1]
https://github.com/OpenTouryoProject/SampleProgram/tree/master/Other/PipesFamilyHouse
--AnonymousPipe(匿名パイプによる親子プロセス間通信)
--StdIOAndPipe(標準入出力による親子プロセス間通信)
-AnonymousPipe(匿名パイプによる親子プロセス間通信)
-StdIOAndPipe(標準入出力による親子プロセス間通信)

----
Tags: [[:プログラミング]], [[:その他、開発の色々]], [[:.NET開発]]


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS