~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Doc/library/socket.rst

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
401
401
   library and needs objects of type :ctype:`struct in_addr`, which is the C type
402
402
   for the 32-bit packed binary this function returns.
403
403
 
 
404
   :func:`inet_aton` also accepts strings with less than three dots; see the
 
405
   Unix manual page :manpage:`inet(3)` for details.
 
406
 
404
407
   If the IPv4 address string passed to this function is invalid,
405
408
   :exc:`socket.error` will be raised. Note that exactly what is valid depends on
406
409
   the underlying C implementation of :cfunc:`inet_aton`.
437
440
 
438
441
   Availability: Unix (maybe not all platforms).
439
442
 
440
 
   .. seealso::
441
 
 
442
 
      :func:`ipaddr.BaseIP.packed`
443
 
         Platform-independent conversion to a packed, binary format.
444
 
 
445
443
   .. versionadded:: 2.3
446
444
 
447
445
 
601
599
   The :meth:`ioctl` method is a limited interface to the WSAIoctl system
602
600
   interface. Please refer to the MSDN documentation for more information.
603
601
 
 
602
   On other platforms, the generic :func:`fcntl.fcntl` and :func:`fcntl.ioctl`
 
603
   functions may be used; they accept a socket object as their first argument.
 
604
 
604
605
   .. versionadded:: 2.6
605
606
 
606
607
 
731
732
 
732
733
Some notes on socket blocking and timeouts: A socket object can be in one of
733
734
three modes: blocking, non-blocking, or timeout.  Sockets are always created in
734
 
blocking mode.  In blocking mode, operations block until complete.  In
 
735
blocking mode.  In blocking mode, operations block until complete or
 
736
the system returns an error (such as connection timed out).  In
735
737
non-blocking mode, operations fail (with an error that is unfortunately
736
738
system-dependent) if they cannot be completed immediately.  In timeout mode,
737
739
operations fail if they cannot be completed within the timeout specified for the
738
 
socket.  The :meth:`setblocking` method is simply a shorthand for certain
739
 
:meth:`settimeout` calls.
 
740
socket or if the system returns an error.  The :meth:`setblocking` method is simply
 
741
a shorthand for certain :meth:`settimeout` calls.
740
742
 
741
743
Timeout mode internally sets the socket in non-blocking mode.  The blocking and
742
744
timeout modes are shared between file descriptors and socket objects that refer
747
749
 
748
750
Note that the :meth:`connect` operation is subject to the timeout setting, and
749
751
in general it is recommended to call :meth:`settimeout` before calling
750
 
:meth:`connect`.
 
752
:meth:`connect` or pass a timeout parameter to :meth:`create_connection`.
 
753
The system network stack may return a connection timeout error
 
754
of its own regardless of any Python socket timeout setting.
751
755
 
752
756
 
753
757
.. method:: socket.setsockopt(level, optname, value)