socket.hpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  Socket.h - Small socket wrapper
4  -------------------
5  begin : Fri Aug 4 2006
6  copyright : (C) 2006 Bas Kemper
7  email : kst@ <my name> .be
8 
9  ***************************************************************************
10  * This library is free software; you can redistribute it and/or *
11  * modify it under the terms of the GNU Lesser General Public *
12  * License as published by the Free Software Foundation; either *
13  * version 2.1 of the License, or (at your option) any later version. *
14  * *
15  * This library is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
18  * Lesser General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU Lesser General Public *
21  * License along with this library; if not, write to the Free Software *
22  * Foundation, Inc., 59 Temple Place, *
23  * Suite 330, Boston, MA 02111-1307 USA *
24  * *
25  ***************************************************************************/
26 #ifndef ORO_COMP_SOCKET_H
27 #define ORO_COMP_SOCKET_H
28 #include <iostream>
29 
30 namespace {
31  class sockbuf;
32 }
33 
34 namespace OCL {
35 namespace TCP {
36  class Socket : public std::ostream {
37  friend class ::sockbuf;
38  private:
42  int socket;
43 
52  bool lineAvailable();
53 
58  void checkBufferOverflow();
59 
63  void rawClose();
64 
68  /* buflength should be at least msglength * 2 in order to avoid problems with memcpy! */
69  #define BUFLENGTH 2000
71  int begin;
72  int ptrpos;
73  int end;
74 
75  public:
81  Socket( int socketID );
82  ~Socket();
83 
87  bool isValid() const;
88 
92  bool dataAvailable();
93 
97  std::string readLine();
98 
102  void close();
103  };
104 } // namespace TCP
105 } // namespace OCL
106 #endif
#define BUFLENGTH
Definition: socket.hpp:69
bool lineAvailable()
Definition: socket.cpp:166
std::string readLine()
Definition: socket.cpp:222
bool dataAvailable()
Definition: socket.cpp:161
void checkBufferOverflow()
Definition: socket.cpp:207
void rawClose()
Definition: socket.cpp:268
Socket(int socketID)
Definition: socket.cpp:141
char buffer[BUFLENGTH]
Definition: socket.hpp:70
bool isValid() const
Definition: socket.cpp:156


ocl
Author(s): OCL Development Team
autogenerated on Mon Mar 23 2020 04:47:19