Package wtf :: Module stream :: Class MinimalSocketStream
[hide private]
[frames] | no frames]

Class MinimalSocketStream

source code

object --+
         |
        MinimalSocketStream

Minimal stream out of a socket

This effectively maps recv to read and sendall to write.


See Also: GenericStream

Instance Methods [hide private]
 
__del__(self) source code
any
__getattr__(self, name)
Delegate all unknown symbol requests to the socket itself
source code
 
__init__(self, sock, shutdown=None)
Initialization
source code
 
close(self)
Close the stream (not necessarily the socket)
source code
str
read(self, size)
Read size bytes (or less) from the socket
source code
 
write(self, data)
Write data to the socket
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  name = '<socket>'
Instance Variables [hide private]
int _shutdown
shutdown parameter on close
socket.socket _sock
The socket in question
Properties [hide private]
bool closed
Is the stream closed?

Inherited from object: __class__

Method Details [hide private]

__getattr__(self, name)
(Qualification operator)

source code 
Delegate all unknown symbol requests to the socket itself
Parameters:
  • name (str) - The symbol to lookup
Returns: any
The looked up symbol
Raises:
  • AttributeError - Symbol not found

__init__(self, sock, shutdown=None)
(Constructor)

source code 
Initialization
Parameters:
  • sock (socket.socket) - The socket in question
  • shutdown (int) - Shutdown parameter on close (socket.SHUT_*). If omitted or None, the close method of the socket is called (if exists).
Overrides: object.__init__

read(self, size)

source code 
Read size bytes (or less) from the socket
Parameters:
  • size (int) - The number of bytes to read (> 0)
Returns: str
The bytes read
Raises:
  • ValueError - The stream is closed
  • socket.error - Something happened to the socket

write(self, data)

source code 
Write data to the socket
Parameters:
  • data (str) - The data to write
Raises:
  • ValueError - The stream is closed
  • socket.error - Something happened to the socket

Property Details [hide private]

closed

Is the stream closed?
Get Method:
unreachable.fget(self)
Type:
bool