ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBMFTransport_TCP Class Reference
+ Inheritance diagram for ilBMFTransport_TCP:
+ Collaboration diagram for ilBMFTransport_TCP:

Public Member Functions

 ilBMFTransport_TCP ($url, $encoding=SOAP_DEFAULT_ENCODING)
 Constructor. More...
 
 _socket_ping ()
 
 send ($msg, $options=NULL)
 Sends and receives SOAP data. More...
 
 _validateUrl ()
 Validates the url data passed to the constructor. More...
 
- Public Member Functions inherited from ilBMFBase_Object
 ilBMFBase_Object ($faultcode='Client')
 Constructor. More...
 
_raiseSoapFault ($str, $detail='', $actorURI='', $code=null, $mode=null, $options=null, $skipmsg=false)
 Raises a SOAP error. More...
 
 __isfault ()
 
__getfault ()
 
 _debug ($string)
 Adds a string to the debug data. More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $headers = array()
 
 $urlparts = null
 
 $url = ''
 
 $incoming_payload = ''
 
 $_userAgent = SOAP_LIBRARY_NAME
 
 $encoding = SOAP_DEFAULT_ENCODING
 
 $result_encoding = 'UTF-8'
 
 $result_content_type
 
 $socket = null
 socket More...
 
- Data Fields inherited from ilBMFBase_Object
 $_debug_flag = false
 Store debugging information in $_debug_data? More...
 
 $_debug_data = ''
 String containing debugging information if $_debug_flag is true. More...
 
 $_encodings = array('ISO-8859-1', 'US-ASCII', 'UTF-8')
 Supported encodings, limited by XML extension. More...
 
 $_myfaultcode = ''
 Fault code. More...
 
 $fault = null
 Recent PEAR_Error object. More...
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Detailed Description

Definition at line 33 of file class.ilBMFTransport_TCP.php.

Member Function Documentation

◆ _socket_ping()

ilBMFTransport_TCP::_socket_ping ( )

Definition at line 65 of file class.ilBMFTransport_TCP.php.

References $result.

Referenced by send().

66  {
67  // XXX how do we restart after socket_shutdown?
68  //if (!$this->socket) {
69  // Create socket resource.
70  $this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
71  if ($this->socket < 0) {
72  return 0;
73  }
74 
75  // Connect.
76  $result = socket_connect($this->socket, $this->urlparts['host'],
77  $this->urlparts['port']);
78  if ($result < 0) {
79  return 0;
80  }
81  //}
82  return 1;
83  }
$result
+ Here is the caller graph for this function:

◆ _validateUrl()

ilBMFTransport_TCP::_validateUrl ( )

Validates the url data passed to the constructor.

Returns
boolean private

Definition at line 142 of file class.ilBMFTransport_TCP.php.

References ilBMFBase_Object\_raiseSoapFault().

Referenced by send().

143  {
144  if (!is_array($this->urlparts) ) {
145  $this->_raiseSoapFault("Unable to parse URL $url");
146  return false;
147  }
148  if (!isset($this->urlparts['host'])) {
149  $this->_raiseSoapFault("No host in URL $url");
150  return false;
151  }
152  if (!isset($this->urlparts['path']) || !$this->urlparts['path']) {
153  $this->urlparts['path'] = '/';
154  }
155 
156  return true;
157  }
& _raiseSoapFault($str, $detail='', $actorURI='', $code=null, $mode=null, $options=null, $skipmsg=false)
Raises a SOAP error.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ilBMFTransport_TCP()

ilBMFTransport_TCP::ilBMFTransport_TCP (   $url,
  $encoding = SOAP_DEFAULT_ENCODING 
)

Constructor.

Parameters
string$urlHTTP url to SOAP endpoint.

public

Definition at line 57 of file class.ilBMFTransport_TCP.php.

References $encoding, and $url.

58  {
59  parent::ilBMFBase_Object('TCP');
60  $this->urlparts = @parse_url($url);
61  $this->url = $url;
62  $this->encoding = $encoding;
63  }

◆ send()

ilBMFTransport_TCP::send (   $msg,
  $options = NULL 
)

Sends and receives SOAP data.

Parameters
string$msgOutgoing POST data.
string$actionSOAP Action header data.
Returns
string|ilBMFFault public

Definition at line 94 of file class.ilBMFTransport_TCP.php.

References ilBMFBase_Object\$fault, $incoming_payload, ilBMFBase_Object\_raiseSoapFault(), _socket_ping(), and _validateUrl().

95  {
96  $this->incoming_payload = '';
97  $this->outgoing_payload = $msg;
98  if (!$this->_validateUrl()) {
99  return $this->fault;
100  }
101 
102  // Check for TCP scheme.
103  if (strcasecmp($this->urlparts['scheme'], 'TCP') == 0) {
104  // Check connection.
105  if (!$this->_socket_ping()) {
106  return $this->_raiseSoapFault('Error connecting to ' . $this->url . '; reason: ' . socket_strerror(socket_last_error($this->socket)));
107  }
108 
109  // Write to the socket.
110  if (!@socket_write($this->socket, $this->outgoing_payload,
111  strlen($this->outgoing_payload))) {
112  return $this->_raiseSoapFault('Error sending data to ' . $this->url . '; reason: ' . socket_strerror(socket_last_error($this->socket)));
113  }
114 
115  // Shutdown writing.
116  if(!socket_shutdown($this->socket, 1)) {
117  return $this->_raiseSoapFault('Cannot change socket mode to read.');
118  }
119 
120  // Read everything we can.
121  while ($buf = @socket_read($this->socket, 1024, PHP_BINARY_READ)) {
122  $this->incoming_payload .= $buf;
123  }
124 
125  // Return payload or die.
126  if ($this->incoming_payload) {
128  }
129 
130  return $this->_raiseSoapFault('Error reveiving data from ' . $this->url);
131  }
132 
133  return $this->_raiseSoapFault('Invalid url scheme ' . $this->url);
134  }
_validateUrl()
Validates the url data passed to the constructor.
& _raiseSoapFault($str, $detail='', $actorURI='', $code=null, $mode=null, $options=null, $skipmsg=false)
Raises a SOAP error.
$fault
Recent PEAR_Error object.
+ Here is the call graph for this function:

Field Documentation

◆ $_userAgent

ilBMFTransport_TCP::$_userAgent = SOAP_LIBRARY_NAME

Definition at line 40 of file class.ilBMFTransport_TCP.php.

◆ $encoding

ilBMFTransport_TCP::$encoding = SOAP_DEFAULT_ENCODING

Definition at line 41 of file class.ilBMFTransport_TCP.php.

Referenced by ilBMFTransport_TCP().

◆ $headers

ilBMFTransport_TCP::$headers = array()

Definition at line 36 of file class.ilBMFTransport_TCP.php.

◆ $incoming_payload

ilBMFTransport_TCP::$incoming_payload = ''

Definition at line 39 of file class.ilBMFTransport_TCP.php.

Referenced by send().

◆ $result_content_type

ilBMFTransport_TCP::$result_content_type

Definition at line 43 of file class.ilBMFTransport_TCP.php.

◆ $result_encoding

ilBMFTransport_TCP::$result_encoding = 'UTF-8'

Definition at line 42 of file class.ilBMFTransport_TCP.php.

◆ $socket

ilBMFTransport_TCP::$socket = null

socket

Definition at line 48 of file class.ilBMFTransport_TCP.php.

◆ $url

ilBMFTransport_TCP::$url = ''

Definition at line 38 of file class.ilBMFTransport_TCP.php.

Referenced by ilBMFTransport_TCP().

◆ $urlparts

ilBMFTransport_TCP::$urlparts = null

Definition at line 37 of file class.ilBMFTransport_TCP.php.


The documentation for this class was generated from the following file: