Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

localsocket.hh

Go to the documentation of this file.
00001 /*
00002 ** localsocket.hh
00003 ** Login : Julien Lemoine <speedblue@happycoders.org>
00004 ** Started on  Sun Mar  2 00:53:36 2003 Julien Lemoine
00005 ** $Id: localsocket.hh,v 1.2 2004/06/01 21:30:53 speedblue Exp $
00006 **
00007 ** Copyright (C) 2003,2004 Julien Lemoine
00008 ** This program is free software; you can redistribute it and/or modify
00009 ** it under the terms of the GNU Lesser General Public License as published by
00010 ** the Free Software Foundation; either version 2 of the License, or
00011 ** (at your option) any later version.
00012 **
00013 ** This program is distributed in the hope that it will be useful,
00014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 ** GNU Lesser General Public License for more details.
00017 **
00018 ** You should have received a copy of the GNU Lesser General Public License
00019 ** along with this program; if not, write to the Free Software
00020 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00021 */
00022 
00023 #include "socket.hh"
00024 
00025 #ifndef LIBSOCKET_WIN
00026 
00027 #ifndef         LOCAL_SOCKET_HH_
00028 # define        LOCAL_SOCKET_HH_
00029 
00030 namespace Network
00031 {
00034   class LocalSocket : public Socket
00035   {
00036   public:
00037     LocalSocket() :
00038       Socket(LOCAL), _filename("")
00039     {}
00040     LocalSocket(PROTO_KIND pkind) :
00041       Socket(LOCAL, pkind), _filename("")
00042     {}
00043 
00044     virtual ~LocalSocket()
00045     {
00046       close();
00047     }
00048 
00049   public:
00051     void                writeto(const std::string& str,
00052                                 const std::string& filename);
00053 
00056     std::string read();
00058     std::string read(int timeout);
00060     std::string read(std::string& filename);
00063     std::string read(std::string& filename, int timeout);
00066     std::string readn(unsigned int size);
00069     std::string readn(int timeout, unsigned int size);
00072     std::string readn(std::string& filename, unsigned int size);
00076     std::string readn(std::string& filename, int timeout, unsigned int size);
00077 
00179 
00180     void        init(const std::string& filename);
00182     void        close();
00183 
00184   protected:
00190     int         _bind(const std::string& filename);
00194     std::string _read_line(int socket);
00199     std::string _read_line(int socket, std::string& filename);
00203     std::string _read_line_bin(int socket, unsigned int size);
00208     std::string _read_line_bin(int socket, std::string& filename,
00209                                unsigned int pkg_size);
00214     void        _write_str(int socket, const std::string& str,
00215                            const std::string& filename) const;
00220     void        _write_str_bin(int socket, const std::string& str,
00221                                const std::string& filename) const;
00222 
00223   protected:
00224     std::string         _filename;
00225   };
00226 }
00227 
00228 #endif      /* !LOCAL_SOCKET_HH_ */
00229 #endif

Generated on Fri Apr 8 06:13:01 2005 for libsocket by  doxygen 1.4.0