Class wrapping a socket object with a file interface.
Methods
|
|
|
|
__init__
|
__init__ (
self,
sock,
mode,
name,
)
Constructor
Arguments
- sock
- the socket object being wrapped
- mode
- mode of this file (string)
- name
- name of this file (string)
|
|
checkMode
|
checkMode ( self, mode )
Private method to check the mode.
This method checks, if an operation is permitted according to
the mode of the file. If it is not, an IOError is raised.
Arguments
- mode
- the mode to be checked (string)
Exceptions
|
|
IOError, '[Errno 9] Bad file descriptor'
|
|
|
close
|
close ( self )
Public method to close the file.
|
|
fileno
|
fileno ( self )
Public method returning the file number.
Returns
file number (int)
|
|
flush
|
flush ( self )
Public method to write all pending bytes.
|
|
isatty
|
isatty ( self )
Public method to indicate whether a tty interface is supported.
Returns
always false
|
|
nWrite
|
nWrite ( self, n )
Private method to write a specific number of pending bytes.
Arguments
- n
- the number of bytes to be written (int)
|
|
pendingWrite
|
pendingWrite ( self )
Public method that returns the number of bytes waiting to be written.
Returns
the number of bytes to be written (int)
|
|
read
|
read ( self, size=-1 )
Public method to read bytes from this file.
Arguments
- size
- maximum number of bytes to be read (int)
Returns
the bytes read (any)
|
|
readline
|
readline ( self, size=-1 )
Public method to read a line from this file.
Arguments
- size
- maximum number of bytes to be read (int)
Returns
one line of text up to size bytes (string)
Note
This method will not block and may return only a part of a
line if that is all that is available.
|
|
readlines
|
readlines ( self, sizehint=-1 )
Public method to read all lines from this file.
Arguments
- sizehint
- hint of the numbers of bytes to be read (int)
Returns
list of lines read (list of strings)
|
|
seek
|
seek (
self,
offset,
whence=0,
)
Public method to move the filepointer.
This method is not supported and always raises an
IOError.
|
|
tell
|
tell ( self )
Public method to get the filepointer position.
This method is not supported and always raises an
IOError.
|
|
truncate
|
truncate ( self, size=-1 )
Public method to truncate the file.
This method is not supported and always raises an
IOError.
|
|
write
|
write ( self, str )
Public method to write a string to the file.
Arguments
- str
- bytes to be written (string)
|
|
writelines
|
writelines ( self, list )
Public method to write a list of strings to the file.
Arguments
- list
- the list to be written (list of string)
|