socket.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003                        Socket.h -  Small socket wrapper
00004                            -------------------
00005     begin                : Fri Aug 4 2006
00006     copyright            : (C) 2006 Bas Kemper
00007     email                : kst@ <my name> .be
00008 
00009  ***************************************************************************
00010  *   This library is free software; you can redistribute it and/or         *
00011  *   modify it under the terms of the GNU Lesser General Public            *
00012  *   License as published by the Free Software Foundation; either          *
00013  *   version 2.1 of the License, or (at your option) any later version.    *
00014  *                                                                         *
00015  *   This library is distributed in the hope that it will be useful,       *
00016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00018  *   Lesser General Public License for more details.                       *
00019  *                                                                         *
00020  *   You should have received a copy of the GNU Lesser General Public      *
00021  *   License along with this library; if not, write to the Free Software   *
00022  *   Foundation, Inc., 59 Temple Place,                                    *
00023  *   Suite 330, Boston, MA  02111-1307  USA                                *
00024  *                                                                         *
00025  ***************************************************************************/
00026 #ifndef ORO_COMP_SOCKET_H
00027 #define ORO_COMP_SOCKET_H
00028 #include <iostream>
00029 
00030 namespace {
00031     class sockbuf;
00032 };
00033 
00034 namespace OCL {
00035 namespace TCP {
00036     class Socket : public std::ostream {
00037         friend class ::sockbuf;
00038         private:
00042             int socket;
00043 
00052             bool lineAvailable();
00053 
00058             void checkBufferOverflow();
00059 
00063             void rawClose();
00064 
00068             /* buflength should be at least msglength * 2 in order to avoid problems with memcpy! */
00069             #define BUFLENGTH 2000
00070             char buffer[BUFLENGTH];
00071             int begin;
00072             int ptrpos;
00073             int end;
00074 
00075         public:
00081             Socket( int socketID );
00082             ~Socket();
00083 
00087             bool isValid() const;
00088 
00092             bool dataAvailable();
00093 
00097             std::string readLine();
00098 
00102             void close();
00103     };
00104 };
00105 };
00106 #endif


ocl
Author(s): OCL Development Team
autogenerated on Thu Jan 2 2014 11:38:08