+++ /dev/null
-<?php
-/*
- OpenIsis - an open implementation of the CDS/ISIS database
- Version 0.8.x (patchlevel see file Version)
- Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- see README for more information
-EOH */
-
-// $Id: Server.php,v 1.5 2003/06/30 09:54:45 kripke Exp $
-
-
-/**
- This class represents the connection to an Isis server.
-
- In general, a server is any object having a request function,
- accepting a single Isis_Rec parameter and returning an Isis_Rec.
-
- This implementation is based on a TCP or UNIX socket.
-
- @version $Revision: 1.5 $
- @license LGPL
- @package Isis
-*/
-class Isis_Server {
- var $host;
- var $port;
- var $sock;
- var $pers;
-
- function Isis_Server ($host, $port = 2042, $pers = 0)
- {
- $this->host = $host;
- $this->port = $port;
- $this->pers = $pers;
- $this->open();
- }
-
- function open ()
- {
- // pfsockopen will reuse an existing socket on same host:port
- // should we use stream_socket_client ???
- $this->sock = $this->pers
- ? pfsockopen( $this->host, $this->port /*, $errno, $errstr*/ )
- : fsockopen( $this->host, $this->port /*, $errno, $errstr*/ );
- // if ( false == $this->sock )
- // echo "could not connect to $host:$port: $errno '$errstr'";
- // stupid PHP prints warnings itself %<
- return $this->sock;
- }
-
-
- function request ( $req )
- {
- if ( !$this->sock && !$this->open() )
- return null;
- // echo "SEND\n", $req->toString(ISIS_REC_TEXT);
- fwrite($this->sock, $req->toString(ISIS_REC_TEXT) . "\n");
- fflush($this->sock);
- $txt = '';
- while ( ($line = fgets($this->sock)) && "\n" != $line ) {
- // error_log( "RETR ". $line );
- $txt .= $line;
- }
- $res = new Isis_Rec;
- $res->parse($txt, ISIS_REC_TEXT);
- // error_log( "GOT ". $res->toString() );
- return $res;
- }
-
-} // class Isis_Server
-?>