00001 /*****************************************************************************
00002 * Author: Valient Gough <vgough@pobox.com>
00003 *
00004 *****************************************************************************
00005 * Copyright (c) 2001, Valient Gough
00006 *
00007 * This library is free software; you can distribute it and/or modify it under
00008 * the terms of the GNU Lesser General Public License (LGPL), as published by
00009 * the Free Software Foundation; either version 2.1 of the License, or (at your
00010 * option) any later version.
00011 *
00012 * This library is distributed in the hope that it will be useful, but WITHOUT
00013 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 * FITNESS FOR A PARTICULAR PURPOSE. See the LGPL in the file COPYING for more
00015 * details.
00016 *
00017 */
00018
00019 #ifndef _PipeServer_incl_
00020 #define _PipeServer_incl_
00021
00022 #include <rel-server/ServerConnector.h>
00023
00024 #include <list>
00025 #include <string>
00026
00027 namespace rel
00028 {
00029
00030 class BinaryCoding;
00031
00032 struct PipeServerData
00033 {
00034 int readChan;
00035 int writeChan;
00036 Pointer<Coding> coding;
00037
00038 PipeServerData() {}
00039 PipeServerData(const PipeServerData &src)
00040 : readChan(src.readChan)
00041 , writeChan(src.writeChan)
00042 , coding(src.coding)
00043 { }
00044 };
00045
00046 class PipeServer : public ServerConnector
00047 {
00048 public:
00049
00050 /* The incoming pipe is the primary connect point. When a client
00051 * connects, it must provide it's own connection point, where data is
00052 * actually communicated between client <-> server. The incoming pipe
00053 * is only for clients to request a new connection to the server.
00054 */
00055 PipeServer(const char *incomingPipe);
00056 ~PipeServer();
00057
00058 Pointer<Coding> accept();
00059
00060 private:
00061 bool acceptConnection();
00062 int openWriteChannel(const char *fileName);
00063 int createReadChannel(const char *fileName);
00064
00065 std::string newPipeName();
00066
00067 // the connectionFD and connectionStream are read-only
00068 int connectionFD;
00069 BinaryCoding *connectionStream;
00070
00071 // list of read/write channels for connected clients
00072 std::list< PipeServerData > connections;
00073 };
00074
00075
00076 } // namespace rel
00077
00078 #endif
00079
1.2.10 written by Dimitri van Heesch,
© 1997-2001