简体   繁体   中英

Socket vs. multiprocessing.connection.Listener in python

I know there are different ways to implement IPC in python such as Pipes and Queue ; But according to the Python's official documentation, There is also an alternative way called Listener and Client .

multiprocessing.connection.Listener is much like socket and both got same functions like accept() , close() , send() and recv() . So if we only focus on IPC purpose , whats difference between these two modules? Which one is more efficient ?

Socket Families

I looked at cpython on github , multiprocessing.connection.Listener uses socket standard library with just one main different point : socket families.

Listeners support these families for communication :

  • AF_PIPE - Named pipe
  • AF_INET - TCP socket
  • AF_UNIX - Unix domain socket

Python's standard socket library supports AF_INET and AF_UNIX well, so we can surely say that the main difference is about AF_PIPE family.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM