Source for file Connection.php
Documentation is available at Connection.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 2004 D.A.Dokter |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: D.A.Dokter <dokter@w20e.com> |
// +----------------------------------------------------------------------+
// $Id: Connection.php,v 1.7 2004/08/06 07:38:54 wyldebeast Exp $
require_once 'Net/HL7/Message.php';
* $conn =& new Net_HL7_Connection('localhost', 8089);
* $req =& new Net_HL7_Message();
* ... set some request attributes
* $res = $conn->send($req);
* The Net_HL7_Connection object represents the tcp connection to the
* HL7 message broker. The Connection has only two useful methods
* (apart from the constructor), send and close. The 'send' method
* takes a Net_HL7_Message object as argument, and also returns a
* Net_HL7_Message object. The send method can be used more than once,
* before the connection is closed.
* The Connection object holds the following fields:
* The prefix to be sent to the HL7 server to initiate the
* message. Defaults to \013.
* End of message signal for HL7 server. Defaults to \034\015.
* @author D.A.Dokter <dokter@w20e.com>
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* Creates a connection to a HL7 server, or returns undef when a
* connection could not be established.are:
* @param mixed Host to connect to
* @param int Port to connect to
$this->_HANDLE = $this->_connect ($host, $port);
$this->_MESSAGE_PREFIX = "\013";
$this->_MESSAGE_SUFFIX = "\034\015";
* Connect to specified host and port
* @param mixed Host to connect to
* @param int Port to connect to
function _connect ($host, $port)
* Sends a Net_HL7_Message object over this connection.
* @param object Instance of Net_HL7_Message
* @return object Instance of Net_HL7_Message
$handle = $this->_HANDLE;
$hl7Msg = $req->toString ();
socket_write($handle, $this->_MESSAGE_PREFIX . $hl7Msg . $this->_MESSAGE_SUFFIX);
while (($buf = socket_read($handle, 256 , PHP_BINARY_READ )) !== false ) {
if(preg_match("/" . $this->_MESSAGE_SUFFIX . "$/", $buf))
// Remove message prefix and suffix
$data = preg_replace("/^" . $this->_MESSAGE_PREFIX . "/", "", $data);
$data = preg_replace("/" . $this->_MESSAGE_SUFFIX . "$/", "", $data);
Documentation generated on Mon, 11 Mar 2019 15:32:34 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|