Package pyGlobus :: Module io :: Class GSITCPSocket
[show private | hide private]
[frames | no frames]

Class GSITCPSocket

IOBase --+
         |
        GSITCPSocket


A simple socket interface to secure Globus IO.

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)
Destroys an instance.
  accept(self, attr)
Blocking server-side TCP connection establishment.
  accept_delegation(self, oids, buffers, time_req)
Accept a credential from a remote entity
  close(self)
Close this socket, if there are no open GSIFile objects using it.
  connect(self, host, port, attr)
Blocking TCP connection establishment.
  create_listener(self, attr, port, backlog)
Create a TCP server socket.
  get_delegated_credential(self)
Return the delegated credential.
  get_local_address(self)
Return the local IP and port.
  get_remote_address(self)
Return the remote IP and port.
  get_security_context(self)
Return the GSS security context.
  init_delegation(self, cred, oids, buffers, time_req)
Delegate a credential to a remote entity.
  listen(self)
Block until a client connection is pending.
  makefile(self, mode, bufsize)
Create a GSIFile object from the socket.
  register_accept(self, attr, callback, arg)
Asynchronous server-side TCP connection establishment.
  register_connect(self, host, port, attr, callback, arg)
Asynchronous TCP connection establishment.
  register_listen(self, callback, arg)
Asynchronous wait until a client connection is pending.
  send(self, str)
Emulates socket.send -- writes a string out over the socket.
  sendall(self, str)
Emulates socket.send -- writes a string out over the socket.
  shutdown(self, how)
This should emulate socket.shutdown -- currently, this routine does nothing (it's simply here as a placeholder).
    Inherited from IOBase
  cancel(self, doCallbacks)
Cancel any outstanding operation registered to this IOBase.
  free_callback(self, cbHandle)
######################################################################### # Free's the underlying memory allocated for the callback structure.
  get_handle(self)
######################################################################## # XXX This handle is only valid as long as this object exists.
  read(self, buffer, maxBytes, waitForBytes)
Blocking TCP or file read
  register_close(self, callback, arg)
Asynchronously close the file or connection.
  register_read(self, buffer, maxBytes, waitForBytes, callback, arg)
Asynchronous TCP or file read.
  register_write(self, data, dataLen, callback, arg)
Asynchronous TCP or file write.
  try_read(self, buffer, maxBytes)
Nonblocking TCP or file read
  try_write(self, data, maxLen)
Nonblocking TCP or file write
  write(self, data, dataLen)
Blocking TCP or file write.

Method Details

__init__(self, handle=None)
(Constructor)

Constructs an instance.

Each instance wraps a globus_io_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_io_handle_t object.
Raises:
IOBaseException - A IOBaseException if unable to initialize the globus modules.
Overrides:
pyGlobus.io.IOBase.__init__

__del__(self)
(Destructor)

Destroys an instance.
Raises:
IOBaseException - A IOBaseException if unable to deactivate the globus modules.
Overrides:
pyGlobus.io.IOBase.__del__

accept(self, attr)

Blocking server-side TCP connection establishment.
Parameters:
attr - A TCPIOAttr object containing the attributes for the new eonnection.
Returns:
A new GSITCPSocket object for the new connection.
Raises:
GSITCPSocketException - A GSITCPSocketException is thrown if a listener was not already created, or an error occures while doing the underlying accept.

accept_delegation(self, oids, buffers, time_req)

Accept a credential from a remote entity

oids is the set of extension oids to add to the credential buffers is the set of extension values (must correspond to oids) time_req is the requested credential lifetime, in seconds.
Returns:
Returns the GSSCred associated with the given parameters.

close(self)

Close this socket, if there are no open GSIFile objects using it.
Overrides:
pyGlobus.io.IOBase.close

connect(self, host, port, attr)

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.
attr - A TCPIOAttr object with the appropriate attributes set.
Raises:
GSITCPSocketException - A GSITCPSocketException is thrown if the handle is currently in use, or an error occurs while making the connection.

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

Create a TCP server 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:
attr - A TCPIOAttr containing the attributes for this server.
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 I/O 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:
GSITCPSocketException - A GSITCPSocketException is thrown if the handle is currently in use, or an error occurs while making the connection.

get_delegated_credential(self)

Return the delegated credential.
Returns:
A GSSCred object.
Raises:
GSITCPSocketException - A GSITCPSocketException is thrown if unable to return the credential.

get_local_address(self)

Return the local IP and port.
Returns:
A tuple containing:
  • The IP address of the local socket.
  • The port number.
Raises:
GSITCPSocketException - A GSITCPSocketException is thrown if a listener was not already created.

get_remote_address(self)

Return the remote IP and port.
Returns:
A tuple containing:
  • The IP address of the remote socket.
  • The port number.
Raises:
GSITCPSocketException - A GSITCPSocketException is thrown if a listener was not already created.

get_security_context(self)

Return the GSS security context.
Returns:
A GSSContext object.
Raises:
GSITCPSocketException - A GSITCPSocketException is thrown if a listener was not already created.

init_delegation(self, cred, oids, buffers, time_req)

Delegate a credential to a remote entity. cred is the credential to delegate oids is the set of extension oids to add to the credential buffers is the set of extension values (must correspond to oids) time_req is the requested credential lifetime, in seconds.

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.
Raises:
GSITCPSocketException - A GSITCPSocketException is thrown if a listener was not already created, or an error occures while doing the underlying listen.

makefile(self, mode='r', bufsize=0)

Create a GSIFile object from the socket. Note: unlike socket.makefile, this routine does NOT dup the socket.

register_accept(self, attr, callback, arg)

Asynchronous server-side TCP connection establishment.

Once the connection has been accepted, the callback function will be called, with the arg and a newly created, connected, handle argument passed to the callback.
Parameters:
attr - A TCPIOAttr object containing the attributes for the new eonnection.
callback -

Function to be called when the security handshake is complete. The function has the following prototype:

'function(arg, handle, result)'

arg is the user argument passed when setting the callback, handle is a SWIG'ized pointer to a globus_io_handle_t, and result is a SWIG'ized pointer to a globus_result_t object.
arg - A user argument to be returned when the callback is executed.
Returns:
A tuple containing:
  • A new instance of GSITCPSocket for the new connetion, this must
not be used until the callback occurs.
  • A callback handle. This can either be free'd with a call
to free_callback, or all outstanding handles will be free'd when the instance is destroyed.
Raises:
GSITCPSocketException - A GSITCPSocketException is thrown if a listener was not already created, or an error occures while doing the underlying register_accept.

register_connect(self, host, port, attr, callback, arg)

Asynchronous TCP connection establishment.

Connect a TCP socket on the specified host/port pair. The connection will be started by this function, and a callback will be invoked when the connection is established.
Parameters:
host - A string containing the host to connect to.
port - An int containing the port to connect to.
attr - A TCPIOAttr object with the appropriate attributes set.
callback -

Function to be called when the security handshake is complete. The function has the following prototype:

'function(arg, handle, result)'

arg is the user argument passed when setting the callback, handle is a SWIG'ized pointer to a globus_io_handle_t, and result is a SWIG'ized pointer to a globus_result_t object.
arg - A user argument to be returned when the callback is executed.
Returns:
A SWIG'ized pointer to a callback handle. This handle can be free'd with a call to free_callback, or it will be free'd when the instance is destroyed.
Raises:
GSITCPSocketException - A GSITCPSocketException if the handle is currently in use, or an error occurs while making the connection.

register_listen(self, callback, arg)

Asynchronous wait until a client connection is pending.

The method will issue a callback when a connection is pending.
Parameters:
callback -

The function to be called when a new connection is pending. The function has the following prototype:

'function(arg, handle, result)'

arg is the user argument passed when setting the callback, handle is a SWIG'ized pointer to a globus_io_handle_t, and result is a SWIG'ized pointer to a globus_result_t object.
arg - A user argument to be returned when the callback is executed.
Returns:
A callback handle. The callback handle can either be free'd with a call to free_callback, or all outstanding handles will be free'd when the instance is destroyed.
Raises:
GSITCPSocketException - A GSITCPSocketException is thrown if a listener was not already created, or an error occures while doing the underlying register_listen.

send(self, str)

Emulates socket.send -- writes a string out over the socket.

sendall(self, str)

Emulates socket.send -- writes a string out over the socket.

shutdown(self, how)

This should emulate socket.shutdown -- currently, this routine does nothing (it's simply here as a placeholder).

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