Package pyGlobus :: Module xio :: Class XioSocket
[show private | hide private]
[frames | no frames]

Class XioSocket

XioBase --+
          |
         XioSocket

Known Subclasses:
GsiSocket

A simple socket interface similar to the Python socket API.

Provides the ability to make strongly authenticated connections using GSI. It supports several modes of authorization and provides optional integrity/privacy to the data.
Method Summary
  __init__(self, handle, stack, transport_driver)
Constructs an instance.
  __del__(self)
Closes the handles if they aren't closed already, then frees the memory associated with the handles if it was allocated
  accept(self)
Blocking server-side TCP connection establishment.
  bind(self, bind_tuple)
binds the socket to a port
  close(self)
close the socket
  connect(self, addr)
Blocking TCP connection establishment.
  dup(self)
Return a new socket object identical to the current one
  fileno(self)
Return the underlying file descriptor
  getpeername(self)
Return the remote address
  getsockname(self)
Return the local address
  getsockopt(self, optname)
Return the value of the socket option To get a list of options available call getopts on the transport driver.
  gettimeout(self)
Return timeout or None
  listen(self, backlog)
Creates a listening TCP socket.
  makefile(self)
Return the underlying file descriptor
  recv(self, buflen, data_desc)
blocking read call
  send(self, data, data_desc)
Emulates socket.send -- writes a string over a socket
  sendall(self, data, data_desc)
Emulates socket.sendall -- writes a complete string over a socket
  setblocking(self, flag)
Sets the socket to be blocking or not.
  setsockopt(self, optname, *value)
Set the options from the socket.
  settimeout(self, timeout)
Sets a timeout for the socket
  shutdown(self, how)
shutdown the reading, writing or both sides of the socket
    Inherited from XioBase
  get_handle(self)
Return the handle

Method Details

__init__(self, handle=None, stack=None, transport_driver=None)
(Constructor)

Constructs an instance.

Each instance wraps a globus_xio_handle_t object. An instance of this class may only have a single open connection at a time. To have more then one open connection, use multiple instances.
Parameters:
handle - An optional argument that should contain a SWIG'ized pointer to a globus_xio_handle_t object.
stack - An optional argument that should be an XioStack object
transport_driver - An optional argument that is the first driver in the stack. Defaults to tcp.
Raises:
XioSocketException - A XioSocketException if unable to initialize the globus modules.
Overrides:
pyGlobus.xio.XioBase.__init__

__del__(self)
(Destructor)

Closes the handles if they aren't closed already, then frees the memory associated with the handles if it was allocated
Overrides:
pyGlobus.xio.XioBase.__del__

accept(self)

Blocking server-side TCP connection establishment.
Returns:
A new XioSocket object for the new connection.
Raises:
XioSocketException - A XioSocketException is thrown if a listener was not already created, or an error occurs while doing the underlying accept.

bind(self, bind_tuple)

binds the socket to a port

Note: This does not follow the python socket semantics exactly, getsockopt does not return the (host,port) it was bound to until listen is called.
Parameters:
bind_tuple -

Must be a tuple that is (hostname, port) port that the socket will listen for connections on. If the port number is 0, then an arbitrary TCP port will be selected. If this is true, and the restrict_port attribute is set to TRUE (the default) and the GLOBUS_TCP_PORT_RANGE environment variable was set when Globus XIO was initialized, then the port will be selected from that range. Otherwise, any port number may be

TypeErrors are raised if the argument is not a tuple or the port is not an int.

close(self)

close the socket

connect(self, addr)

Blocking TCP connection establishment.

connect a TCP socket on the specified host/port pair.
Parameters:
addr - A tuple (host,port) where host is a string and port is an int.
Raises:
XioSocketException - A XioSocketException is thrown if the handle is currently in use, or an error occurs while making the connection.

dup(self)

Return a new socket object identical to the current one

Not implemented

fileno(self)

Return the underlying file descriptor

Not implemented

getpeername(self)

Return the remote address
Returns:
The remote address is retuned in a (host,port) tuple
Raises:
XioSocketException - A XioSocketException is raised if there is a problem getting the peername.

getsockname(self)

Return the local address

getsockopt(self, optname)

Return the value of the socket option To get a list of options available call getopts on the transport driver.
Parameters:
optname - is an xioc.OPTION you get this by calling getopts on the driver and selecting the option from the list returned.
Raises:
XioSocketException - A XioSocketException is raised if something went wrong

gettimeout(self)

Return timeout or None

listen(self, backlog)

Creates a listening TCP socket.

Creates a socket handle capable of accepting new TCP connections from other hosts or processes. In order to actually listen for connections, you must call either listen or register listen on this instance.
Parameters:
backlog - The backlog parameter indicates he maximum length of the system's queue of pending connections. Any connection attempts when the queue is full will fail. If backlog is equal to -1, then the system-specific maximum queue length will be used.
Returns:
An int containing the port the server will listen on.
Raises:
XioSocketException - A XioSocketException is thrown if the handle is currently in use, or an error occurs while making the connection.

makefile(self)

Return the underlying file descriptor

Not implemented

recv(self, buflen, data_desc=None)

blocking read call
Parameters:
buflen - - an int telling how much data to read
data_desc - - optional argument that can control how the driver behaves. The interface to call cntl on the data_descriptor is currently not exposed.
Returns:
A string read from the handle
Raises:
XioSocketException - A XioSocketException is raised if there is a problem reading from the handle

send(self, data, data_desc=None)

Emulates socket.send -- writes a string over a socket
Parameters:
data - - a string that will be written to the handle
data_desc - - optional argument that can control how the driver behaves. The interface to call cntl on the data_descriptor is currently not exposed.
Returns:
The number of bytes written
Raises:
XioSocketException - A XioSocketException is raised if there is a problem writing to the handle

sendall(self, data, data_desc=None)

Emulates socket.sendall -- writes a complete string over a socket
Parameters:
data - - a string that will be written to the handle
data_desc - - optional argument that can control how the driver behaves. The interface to call cntl on the data_descriptor is currently not exposed.
Raises:
XioSocketException - A XioSocketException is raised if there is a problem writing to the handle

setblocking(self, flag)

Sets the socket to be blocking or not.
Parameters:
flag - a boolean

setsockopt(self, optname, *value)

Set the options from the socket. To get a list of options available call getopts on the transport driver.
Parameters:
optname - is a string to get a list of options call getopts on the driver and selecting the option from the list returned.
value - can be booleans, strings or ints but it must make sense with the option that you are using
Returns:
None
Raises:
XioSocketException - A XioSocketException is raised if there is a problem setting the socket option, a KeyError is raised if the option is invalid

settimeout(self, timeout)

Sets a timeout for the socket

shutdown(self, how)

shutdown the reading, writing or both sides of the socket

Not implemented

Generated by Epydoc 2.1 on Tue Apr 4 14:32:56 2006 http://epydoc.sf.net