gdescriptor.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
20 
21 #ifndef G_DESCRIPTOR_H
22 #define G_DESCRIPTOR_H
23 
24 #include "gdef.h"
25 #include "gnet.h"
26 #include <iostream>
27 
29 namespace GNet
30 {
31  class Descriptor ;
32 }
33 
38 {
39 public:
40  Descriptor() ;
42 
43  explicit Descriptor( SOCKET ) ;
45 
46  bool valid() const ;
48 
49  static Descriptor invalid() ;
51 
52  SOCKET fd() const ;
54 
55  bool operator<( const Descriptor & other ) const ;
57 
58 private:
59  SOCKET m_fd ;
60 } ;
61 
63 namespace GNet
64 {
65  inline
66  std::ostream & operator<<( std::ostream & stream , const Descriptor & d )
67  {
68  stream << d.fd() ;
69  return stream ;
70  }
71 }
72 
73 #endif
74 
static Descriptor invalid()
Returns an invalid descriptor.
Definition: gdescriptor.cpp:30
Network classes.
bool operator<(const Descriptor &other) const
Comparison operator.
Definition: gdescriptor.cpp:40
A network file descriptor.
Definition: gdescriptor.h:37
SOCKET fd() const
Returns the low-level descriptor.
Definition: gdescriptor.cpp:35
Descriptor()
Default constructor.
bool valid() const
Returns true if the descriptor is valid.
std::ostream & operator<<(std::ostream &stream, const Descriptor &d)
Definition: gdescriptor.h:66