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

Class XioSocket


A simple socket interface similar to the Python Socket API.

Provides the ability to make strongly authenticated connetions using GSI. It supports several modes of authorization and provides optional integrity/privacy to the data.
Method Summary
  __init__(self, handle)
Constructs an instance.
  __del__(self)
  accept(self)
Blocking server-side TCP connection establishment.
  close(self)
Close this socket, if there are no open XIOFile objects using it.
  connect(self, host, port)
Blocking TCP connection establishment.
  create_listener(self, port, backlog)
Creates a listening TCP socket.
  get_handle(self)
  getpeername(self)
  getsockname(self)
  listen(self)
Block until a client connection is pending.
  read(self, buffer, waitForBytes, data)
blocking read call
  send(self, writeString)
blocking write call
  sendall(self, data)
  settimeout(self, timeout)
Sets a timeout for the socket

Method Details

__init__(self, handle=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.
Raises:
XioSocketException - A XioSocketException if unable to initialize the globus modules.

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 occures while doing the underlying accept.

close(self)

Close this socket, if there are no open XIOFile objects using it.

connect(self, host, port)

Blocking TCP connection establishment.

Connect a TCP socket on the specified host/port pair.
Parameters:
host - A string containing the host to connect to.
port - An int containing the port to connect to.
Raises:
XioSocketException - A XioSocketException is thrown if the handle is currently in use, or an error occurs while making the connection.

create_listener(self, port=0, backlog=-1)

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:
port - The TCP 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 chosen.
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.

listen(self)

Block until a client connection is pending.

This method will block until a connection is pending. Once this method returns, accept may be called to return a new GSITCPSocket object.

read(self, buffer, waitForBytes=1, data=None)

blocking read call
Parameters:
buffer - - A pyGlobus.util.Buffer object
waitForBytes - - an int telling how many bytes to wait to recieve before returning
data - - a XioDataDescriptor object
Returns:
A string read from the handle
Raises:
XioSocketException - A XioSocketException is raised if there is a problem reading from the handle

send(self, writeString)

blocking write call
Parameters:
writeString - - a string that will be written to the handle
Returns:
The number of bytes written
Raises:
XioFileException - A XioFileException is raised if there is a problem writing to the handle

settimeout(self, timeout)

Sets a timeout for the socket

Generated by Epydoc 2.1 on Wed Mar 30 12:38:31 2005 http://epydoc.sf.net