[issue14310] Socket duplication for windows

Kristján Valur Jónsson report at bugs.python.org
Thu Mar 15 02:38:07 CET 2012


New submission from Kristján Valur Jónsson <kristjan at ccpgames.com>:

winsock natively supports the duplciation of sockets for use on different processes.  This patch proposes to add that functionality:
socket.duplicate(target_pid) gets a bytes representation of the duplicate socket, usable for the target process.
socket.socket(x,y,z,data) creates the socket object from the bytes representation.

The patch contains a test using multiprocessing that works.
Note that multiprocessing already contains its own code to achieve this, and that code can possibly be simplified with this patch.

Note also the new function "duplicate."  Perhaps "dup(target_pid) would be better?  But it would have different semantics.  
Also notice how we overload the "fromfd" parameter in socket.socket() to recreate a socket from a bytes representation.  Maybe this is not ideal?
Looking for thoughs here.

----------
components: Interpreter Core
files: duplicate.patch
keywords: patch
messages: 155842
nosy: krisvale
priority: normal
severity: normal
status: open
title: Socket duplication for windows
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file24854/duplicate.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14310>
_______________________________________


More information about the Python-bugs-list mailing list