Back to index

python3.2  3.2.2
Public Member Functions | Private Attributes
socket.SocketIO Class Reference
Inheritance diagram for socket.SocketIO:
Inheritance graph
[legend]
Collaboration diagram for socket.SocketIO:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def readinto
def write
def readable
def writable
def fileno
def name
def mode
def close
def __new__
def register
def __instancecheck__
def __subclasscheck__

Private Attributes

 _sock
 _mode
 _reading
 _writing
 _timeout_occurred

Detailed Description

Raw I/O implementation for stream sockets.

This class supports the makefile() method on sockets.  It provides
the raw I/O interface on top of a socket object.

Definition at line 233 of file socket.py.


Constructor & Destructor Documentation

def socket.SocketIO.__init__ (   self,
  sock,
  mode 
)

Definition at line 250 of file socket.py.

00250 
00251     def __init__(self, sock, mode):
00252         if mode not in ("r", "w", "rw", "rb", "wb", "rwb"):
00253             raise ValueError("invalid mode: %r" % mode)
00254         io.RawIOBase.__init__(self)
00255         self._sock = sock
00256         if "b" not in mode:
00257             mode += "b"
00258         self._mode = mode
00259         self._reading = "r" in mode
00260         self._writing = "w" in mode
00261         self._timeout_occurred = False

Here is the caller graph for this function:


Member Function Documentation

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def socket.SocketIO.close (   self)
Close the SocketIO object.  This doesn't close the underlying
socket, except if all references to it have disappeared.

Definition at line 331 of file socket.py.

00331 
00332     def close(self):
00333         """Close the SocketIO object.  This doesn't close the underlying
00334         socket, except if all references to it have disappeared.
00335         """
00336         if self.closed:
00337             return
00338         io.RawIOBase.close(self)
00339         self._sock._decref_socketios()
00340         self._sock = None
00341 

Here is the call graph for this function:

Here is the caller graph for this function:

def socket.SocketIO.fileno (   self)
Return the file descriptor of the underlying socket.

Definition at line 314 of file socket.py.

00314 
00315     def fileno(self):
00316         """Return the file descriptor of the underlying socket.
00317         """
00318         self._checkClosed()
00319         return self._sock.fileno()

Here is the call graph for this function:

Here is the caller graph for this function:

def socket.SocketIO.mode (   self)

Definition at line 328 of file socket.py.

00328 
00329     def mode(self):
00330         return self._mode

Here is the caller graph for this function:

def socket.SocketIO.name (   self)

Definition at line 321 of file socket.py.

00321 
00322     def name(self):
00323         if not self.closed:
00324             return self.fileno()
00325         else:
00326             return -1

Here is the call graph for this function:

Here is the caller graph for this function:

def socket.SocketIO.readable (   self)
True if the SocketIO is open for reading.

Definition at line 304 of file socket.py.

00304 
00305     def readable(self):
00306         """True if the SocketIO is open for reading.
00307         """
00308         return self._reading and not self.closed

Here is the call graph for this function:

def socket.SocketIO.readinto (   self,
  b 
)
Read up to len(b) bytes into the writable buffer *b* and return
the number of bytes read.  If the socket is non-blocking and no bytes
are available, None is returned.

If *b* is non-empty, a 0 return value indicates that the connection
was shutdown at the other end.

Definition at line 262 of file socket.py.

00262 
00263     def readinto(self, b):
00264         """Read up to len(b) bytes into the writable buffer *b* and return
00265         the number of bytes read.  If the socket is non-blocking and no bytes
00266         are available, None is returned.
00267 
00268         If *b* is non-empty, a 0 return value indicates that the connection
00269         was shutdown at the other end.
00270         """
00271         self._checkClosed()
00272         self._checkReadable()
00273         if self._timeout_occurred:
00274             raise IOError("cannot read from timed out object")
00275         while True:
00276             try:
00277                 return self._sock.recv_into(b)
00278             except timeout:
00279                 self._timeout_occurred = True
00280                 raise
00281             except error as e:
00282                 n = e.args[0]
00283                 if n == EINTR:
00284                     continue
00285                 if n in _blocking_errnos:
00286                     return None
00287                 raise

Here is the call graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def socket.SocketIO.writable (   self)
True if the SocketIO is open for writing.

Definition at line 309 of file socket.py.

00309 
00310     def writable(self):
00311         """True if the SocketIO is open for writing.
00312         """
00313         return self._writing and not self.closed

Here is the call graph for this function:

def socket.SocketIO.write (   self,
  b 
)
Write the given bytes or bytearray object *b* to the socket
and return the number of bytes written.  This can be less than
len(b) if not all data could be written.  If the socket is
non-blocking and no bytes could be written None is returned.

Definition at line 288 of file socket.py.

00288 
00289     def write(self, b):
00290         """Write the given bytes or bytearray object *b* to the socket
00291         and return the number of bytes written.  This can be less than
00292         len(b) if not all data could be written.  If the socket is
00293         non-blocking and no bytes could be written None is returned.
00294         """
00295         self._checkClosed()
00296         self._checkWritable()
00297         try:
00298             return self._sock.send(b)
00299         except error as e:
00300             # XXX what about EINTR?
00301             if e.args[0] in _blocking_errnos:
00302                 return None
00303             raise

Here is the call graph for this function:


Member Data Documentation

Definition at line 257 of file socket.py.

Definition at line 258 of file socket.py.

Definition at line 254 of file socket.py.

Definition at line 260 of file socket.py.

Definition at line 259 of file socket.py.


The documentation for this class was generated from the following file: