Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 4125

php-manual-pt_BR-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>SAMConnection-&#62;connect()</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Manual do PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="SAM - Simple Asynchronous Messaging"
HREF="ref.sam.html"><LINK
REL="PREVIOUS"
TITLE="SAMConnection->commit()"
HREF="function.samconnection-commit.html"><LINK
REL="NEXT"
TITLE="SAMConnection->__construct()"
HREF="function.samconnection-constructor.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual do PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.samconnection-commit.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.samconnection-constructor.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.samconnection-connect"
></A
>SAMConnection-&#62;connect()</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN195713"
></A
><P
>    (no version information, might be only in CVS)</P
>SAMConnection-&#62;connect()&nbsp;--&nbsp;
   Establishes a connection to a Messaging Server
  </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN195716"
></A
><H2
>Descrição</H2
>class <B
CLASS="classname"
>SAMConnection</B
> { <BR
></BR
>bool <B
CLASS="methodname"
>connect</B
> ( string protocol [, array properties] )<BR
></BR
>}<P
>&#13;   Calling the "connect" method on a SAMConnection object connects the PHP
   script to a messaging server. No messages can be sent or received until a
   connection is made.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN195731"
></A
><H2
>Parâmetros</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>protocol</CODE
></DT
><DD
><P
>&#13;       A structured string identifying the protocol to be used when
       attempting to connect to the messaging server. The supported protocols
       are represented by constants which are normally used but if required
       the string may be composed dynamically by the script.
       The string is made up of 2 parts, the first being the protocol
       identifier and the second a protocol option. The two parts are
       seperated by a colon (:) character. Acceptable values are described by
       the following table:
       <DIV
CLASS="informaltable"
><P
></P
><A
NAME="AEN195740"
></A
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Protocol string</TH
><TH
>Constant</TH
><TH
>Usage</TH
></TR
></THEAD
><TBODY
><TR
><TD
>mqtt</TD
><TD
>SAM_MQTT</TD
><TD
>Use the MQTT (MQ Telemetry Transport) protocol connecting as a client to a server.</TD
></TR
><TR
><TD
>wmq</TD
><TD
>SAM_WMQ</TD
><TD
>Use the IBM MQSeries protocol connecting as a client to a remote messaging
               server. This is equivalent to "wmq:client" (SAM_WMQ_CLIENT). At least a broker name
               (SAM_BROKER) must be specified in the options array.</TD
></TR
><TR
><TD
>wmq:client</TD
><TD
>SAM_WMQ_CLIENT</TD
><TD
>Use the IBM MQSeries protocol connecting as a client to a remote messaging
               server. At least a broker name (SAM_BROKER) must be specified in the options array.
               </TD
></TR
><TR
><TD
>wmq:bindings</TD
><TD
>SAM_WMQ_BINDINGS</TD
><TD
>Use the IBM MQSeries protocol connecting to a local messaging server and
               communicating via shared memory. At least a broker name (SAM_BROKER) must be
               specified in the options array.</TD
></TR
><TR
><TD
>wpm</TD
><TD
>SAM_WPM</TD
><TD
>Use the IBM WebSphere Platform Messaging protocol to connect to the
               messaging infrastructure of a WebSphere Application server or cluster. A bus name
               must be specified in the options array (SAM_BUS) and endpoint and target chain
               may also be specified.</TD
></TR
><TR
><TD
>rtt</TD
><TD
>SAM_RTT</TD
><TD
>Use the IBM Realtime transport protocol to connect to the
               messaging infrastructure.</TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>
      </P
></DD
><DT
><CODE
CLASS="parameter"
>properties</CODE
></DT
><DD
><P
>&#13;       An optional associative array of properties to describe the details of
       the connection required. The following table lists the available
       property names and accepted values:
       <DIV
CLASS="informaltable"
><P
></P
><A
NAME="AEN195777"
></A
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><THEAD
><TR
><TH
>Property name</TH
><TH
>default</TH
><TH
>Usage</TH
></TR
></THEAD
><TBODY
><TR
><TD
>SAM_BROKER</TD
><TD
>none</TD
><TD
>&#13;                The name of the broker or queue manager running on the messaging server.
                <P
>&#13;                This property must be set if using one of the variants of the WebSphere
                MQSeries protocol (SAM_WMQ, SAM_WMQ_CLIENT, SAM_WMQ_BINDINGS).
                </P
>
               </TD
></TR
><TR
><TD
>SAM_HOST</TD
><TD
>localhost</TD
><TD
>&#13;                The hostname of the machine on which the messaging server is running.
               </TD
></TR
><TR
><TD
>SAM_PORT</TD
><TD
>1414 for SAM_WMQ,
                1506 for SAM_WPM,
                or 1883 for SAM_MQTT
               </TD
><TD
>&#13;                The port number on which to attempt communication with the messaging server.
               </TD
></TR
><TR
><TD
>SAM_EXPIRE_AFTER</TD
><TD
>0</TD
><TD
>&#13;                Time in milliseconds after which a message is deemed to have expired and can be
                deleted from queues. The default value is 0 indicating the message never expires.
                <P
>&#13;                Warning: Not yet implemented!
                </P
>
               </TD
></TR
><TR
><TD
>SAM_MESSAGE_PERSISTENCE</TD
><TD
>none</TD
><TD
>&#13;                Selects whether messages are made persistent during delivery. The value may be
                SAM_PERSISTENT or SAM_NON_PERSISTENT. The default is dependant on the connection
                type and capabilities of the Messaging Server to which the connection is made.
                <P
>&#13;                Warning: Not yet implemented!
                </P
>
               </TD
></TR
><TR
><TD
>SAM_MQTT_CLEANSTART</TD
><TD
><TT
CLASS="constant"
><B
>FALSE</B
></TT
></TD
><TD
>&#13;                Optional connect option to indicate to an MQTT server that all previous connection data
                for this client should be removed and that subscriptions should be deleted when the client
                disconnects explicitly or unexpectedly. Setting the value to <TT
CLASS="constant"
><B
>TRUE</B
></TT
> causes SAM to discard
                any subscription already in place for the client when it connects and also to discard
                subscription when the client disconnects. Setting the option to <TT
CLASS="constant"
><B
>FALSE</B
></TT
>, or using the
                default, allows subscriptions to be durable and survive across client disconnects.
               </TD
></TR
><TR
><TD
>SAM_PASSWORD</TD
><TD
>none</TD
><TD
>&#13;                The password to be used when the Messaging Server to which the connection is being made requires authentication.
               </TD
></TR
><TR
><TD
>SAM_TRANSACTIONS</TD
><TD
>SAM_AUTO</TD
><TD
>&#13;                Indicates how transactions are handled on this connection. The value may be SAM_AUTO (the default) to allow automatic handling on a per operation basis or SAM_MANUAL to allow the PHP script to control the transaction boundaries. If SAM_MANUAL is used any in-flight transactions will be rolled back if the script is terminated or the connection is closed without a commit being executed.
                </TD
></TR
><TR
><TD
>SAM_USERID</TD
><TD
>none</TD
><TD
>&#13;                The user id to be used when the Messaging Server to which the connection is being made requires authentication.
                </TD
></TR
><TR
><TD
>SAM_WPM_DUR_SUB_HOME</TD
><TD
>none</TD
><TD
>&#13;                The name of the messaging engine where durable subscriptions are managed. (WPM ONLY).
                </TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN195831"
></A
><H2
>Valores de retornado</H2
><P
>&#13;   This method returns <TT
CLASS="constant"
><B
>FALSE</B
></TT
> if an error occurs.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN195835"
></A
><H2
>Exemplos</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN195838"
></A
><P
><B
>Exemplo 1. 
     Creating a connection to a Messaging Server using the IBM MQSeries
     protocol (WMQ)
    </B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">connect</font><font color="#007700">(</font><font color="#0000BB">SAM_WMQ</font><font color="#007700">, array(</font><font color="#0000BB">SAM_HOST </font><font color="#007700">=&gt; </font><font color="#DD0000">'Myhost.myco.com'</font><font color="#007700">, </font><font color="#0000BB">SAM_PORT </font><font color="#007700">=&gt; </font><font color="#0000BB">1506</font><font color="#007700">, </font><font color="#0000BB">SAM_BROKER </font><font color="#007700">=&gt; </font><font color="#DD0000">'MyBroker'</font><font color="#007700">));<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN195842"
></A
><P
><B
>Exemplo 2. 
     Creating a connection with application transaction control and default
     host and port values
    </B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">connect</font><font color="#007700">(</font><font color="#0000BB">SAM_WMQ</font><font color="#007700">, array(</font><font color="#0000BB">SAM_BROKER </font><font color="#007700">=&gt; </font><font color="#DD0000">'MyBroker'</font><font color="#007700">, </font><font color="#0000BB">SAM_TRANSACTIONS </font><font color="#007700">=&gt; </font><font color="#0000BB">SAM_MANUAL</font><font color="#007700">));<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN195846"
></A
><P
><B
>Exemplo 3. 
     Creating a connection to a Messaging Server using the IBM WebSphere
     Platform Messaging protocol (WPM)
    </B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$conn</font><font color="#007700">-&gt;</font><font color="#0000BB">connect</font><font color="#007700">(</font><font color="#0000BB">SAM_WPM</font><font color="#007700">, array(</font><font color="#0000BB">SAM_ENDPOINTS </font><font color="#007700">=&gt; </font><font color="#DD0000">'localhost:7278:BootstrapBasicMessaging'</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">SAM_BUS </font><font color="#007700">=&gt; </font><font color="#DD0000">'Bus1'</font><font color="#007700">, </font><font color="#0000BB">SAM_TARGETCHAIN </font><font color="#007700">=&gt; </font><font color="#DD0000">'InboundBasicMessaging'</font><font color="#007700">));<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN195849"
></A
><H2
>Veja também</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.samconnection-isconnected.html"
>SAMConnection-&#62;isConnected()</A
></TD
></TR
><TR
><TD
><A
HREF="function.samconnection-disconnect.html"
>SAMConnection-&#62;disconnect()</A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.samconnection-commit.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Principal</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.samconnection-constructor.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SAMConnection-&#62;commit()</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.sam.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SAMConnection-&#62;__construct()</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>