Table of Contents

Class: GSITCPSocket ./pyGlobus/io.py

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.

Extends:

pyGlobus.io.IOBase.IOBase

Base Classes   
IOBase
Methods   
__del__
__init__
accept
accept_delegation
close
connect
create_listener
get_delegated_credential
get_local_address
get_remote_address
get_security_context
init_delegation
listen
makefile
register_accept
register_connect
register_listen
send
sendall
shutdown
  __del__ 
__del__ ( self )

Destroys an instance.

Raises:

An IOBaseException is thrown if unable to deactivate the globus modules.

  __init__ 
__init__ ( self,  handle=None )

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.

Arguments:

  • handle An optional argument that should contain a SWIG'ized pointer to a globus_io_handle_t object.

Raises:

An IOBaseException is thrown if unable to initialize the globus modules.

  accept 
accept ( self,  attr )

Blocking server-side TCP connection establishment.

Arguments:

  • attr A TCPIOAttr object containing the attributes for the new eonnection.

Raises:

A GSITCPSocketException is thrown if a listener was not already created, or an error occures while doing the underlying accept.

Returns:

A new GSITCPSocket object for the new connection.

Exceptions   
ex
  accept_delegation 
accept_delegation (
        self,
        oids,
        buffers,
        time_req,
        )

Exceptions   
ex
  close 
close ( self )

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

  connect 
connect (
        self,
        host,
        port,
        attr,
        )

Blocking TCP connection establishment.

Connect a TCP socket on the specified host/port pair.

Arguments:

  • 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:

A GSITCPSocketException is thrown if the handle is currently in use, or an error occurs while making the connection.

Exceptions   
ex
  create_listener 
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.

Arguments

  • 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.

Raises:

A GSITCPSocketException is thrown if the handle is currently in use, or an error occurs while making the connection.

Returns:

An int containing the port the server will listen on.

Exceptions   
ex
  get_delegated_credential 
get_delegated_credential ( self )

Return the delegated credential.

Raises:

A GSSCredException is thrown if unable to return the credential.

Returns:

A GSSCred object.

Exceptions   
ex
  get_local_address 
get_local_address ( self )

Return the local IP and port.

Raises:

A GSITCPSocketException is thrown if a listener was not already created.

Returns:

A tuple containing:
  • The IP address of the local socket.

  • The port number.

Exceptions   
ex
  get_remote_address 
get_remote_address ( self )

Return the remote IP and port.

Raises:

A GSITCPSocketException is thrown if a listener was not already created.

Returns:

A tuple containing:
  • The IP address of the remote socket.

  • The port number.

Exceptions   
ex
  get_security_context 
get_security_context ( self )

Return the GSS security context.

Raises:

A GSITCPSocketException is thrown if a listener was not already created.

Returns:

A GSSContext object.

Exceptions   
ex
  init_delegation 
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.

Experimental GSS extensions

Exceptions   
ex
  listen 
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:

A GSITCPSocketException is thrown if a listener was not already created, or an error occures while doing the underlying listen.

Exceptions   
ex
  makefile 
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 
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.

Arguments:

  • 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.

Raises:

A GSITCPSocketException is thrown if a listener was not already created, or an error occures while doing the underlying register_accept.

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.

Exceptions   
ex
  register_connect 
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.

Arguments:

  • 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.

Raises:

A GSITCPSocketException is thrown if the handle is currently in use, or an error occurs while making the connection.

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.

Exceptions   
ex
  register_listen 
register_listen (
        self,
        callback,
        arg,
        )

Asynchronous wait until a client connection is pending.

The method will issue a callback when a connection is pending.

Arguments:

  • 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.

Raises:

A GSITCPSocketException is thrown if a listener was not already created, or an error occures while doing the underlying register_listen.

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.

Exceptions   
ex
  send 
send ( self,  str )

Emulates socket.send
writes a string out over the socket.
  sendall 
sendall ( self,  str )

Emulates socket.send
writes a string out over the socket.
  shutdown 
shutdown ( self,  how )

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

Table of Contents

This document was automatically generated on Tue Feb 4 16:47:03 2003 by HappyDoc version 2.1