]> granicus.if.org Git - python/commitdiff
Merge socket doc changes from 3.3
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 4 Dec 2013 20:15:24 +0000 (21:15 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 4 Dec 2013 20:15:24 +0000 (21:15 +0100)
1  2 
Doc/library/socket.rst

index b01238c29dd46080c3902aa3ad19197e2829f7bf,3bd1c31f496d444229450e5e23dd4444afc33245..c2e9f008bb42f8541e238a0f09ad2f3ddc463a53
@@@ -305,6 -297,43 +312,57 @@@ Constant
     this platform.
  
  
 -.. function:: socket([family[, type[, proto]]])
+ Functions
+ ^^^^^^^^^
+ Creating sockets
+ ''''''''''''''''
+ The following functions all create :ref:`socket objects <socket-objects>`.
 -   constants. The protocol number is usually zero and may be omitted in that
 -   case or :const:`CAN_RAW` in case the address family is :const:`AF_CAN`.
++.. function:: socket(family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None)
+    Create a new socket using the given address family, socket type and protocol
+    number.  The address family should be :const:`AF_INET` (the default),
+    :const:`AF_INET6`, :const:`AF_UNIX`, :const:`AF_CAN` or :const:`AF_RDS`. The
+    socket type should be :const:`SOCK_STREAM` (the default),
+    :const:`SOCK_DGRAM`, :const:`SOCK_RAW` or perhaps one of the other ``SOCK_``
++   constants. The protocol number is usually zero and may be omitted or in the
++   case where the address family is :const:`AF_CAN` the protocol should be one
++   of :const:`CAN_RAW` or :const:`CAN_BCM`.
++
++   The newly created socket is :ref:`non-inheritable <fd_inheritance>`.
+    .. versionchanged:: 3.3
+       The AF_CAN family was added.
+       The AF_RDS family was added.
++   .. versionchanged:: 3.4
++       The CAN_BCM protocol was added.
++
++   .. versionchanged:: 3.4
++      The returned socket is now non-inheritable.
++
+ .. function:: socketpair([family[, type[, proto]]])
+    Build a pair of connected socket objects using the given address family, socket
+    type, and protocol number.  Address family, socket type, and protocol number are
+    as for the :func:`.socket` function above. The default family is :const:`AF_UNIX`
+    if defined on the platform; otherwise, the default is :const:`AF_INET`.
+    Availability: Unix.
++   The newly created sockets are :ref:`non-inheritable <fd_inheritance>`.
++
+    .. versionchanged:: 3.2
+       The returned socket objects now support the whole socket API, rather
+       than a subset.
++   .. versionchanged:: 3.4
++      The returned sockets are now non-inheritable.
++
  .. function:: create_connection(address[, timeout[, source_address]])
  
     Connect to a TCP service listening on the Internet *address* (a 2-tuple
        support for the :keyword:`with` statement was added.
  
  
 -.. function:: fromfd(fd, family, type[, proto])
++.. function:: fromfd(fd, family, type, proto=0)
+    Duplicate the file descriptor *fd* (an integer as returned by a file object's
+    :meth:`fileno` method) and build a socket object from the result.  Address
+    family, socket type and protocol number are as for the :func:`.socket` function
+    above. The file descriptor should refer to a socket, but this is not checked ---
+    subsequent operations on the object may fail if the file descriptor is invalid.
+    This function is rarely needed, but can be used to get or set socket options on
+    a socket passed to a program as standard input or output (such as a server
+    started by the Unix inet daemon).  The socket is assumed to be in blocking mode.
++   The newly created socket is :ref:`non-inheritable <fd_inheritance>`.
++
++   .. versionchanged:: 3.4
++      The returned socket is now non-inheritable.
++
+ .. function:: fromshare(data)
+    Instantiate a socket from data obtained from the :meth:`socket.share`
+    method.  The socket is assumed to be in blocking mode.
+    Availability: Windows.
+    .. versionadded:: 3.3
+ .. data:: SocketType
+    This is a Python type object that represents the socket object type. It is the
+    same as ``type(socket(...))``.
+ Other functions
+ '''''''''''''''
+ The :mod:`socket` module also offers various network-related services:
  .. function:: getaddrinfo(host, port, family=0, type=0, proto=0, flags=0)
  
     Translate the *host*/*port* argument into a sequence of 5-tuples that contain