libUTL++
ServerSocket.h
1 #pragma once
2 
4 
5 #include <libutl/FDstream.h>
6 #include <libutl/InetHostAddress.h>
7 #include <libutl/ServerSocket.h>
8 
10 
11 UTL_NS_BEGIN;
12 
14 
22 
24 class ServerSocket : public Object
25 {
28 
29 public:
30  virtual int compare(const Object& rhs) const;
31 
33  virtual FDstream* makeSocket() const = 0;
34 
41  virtual bool accept(FDstream* socket, InetHostAddress* clientAddr = nullptr) = 0;
42 
44  int
45  fd() const
46  {
47  return _fd;
48  }
49 
51  void close();
52 
54  void setNonBlocking();
55 
56 protected:
57  int _fd;
58 
59 private:
60  void
61  init()
62  {
63  _fd = -1;
64  }
65  void
66  deInit()
67  {
68  close();
69  }
70 };
71 
73 
74 UTL_NS_END;
void deInit()
De-initialize UTL++.
Local host server socket.
Definition: ServerSocket.h:24
int fd() const
Get the file descriptor.
Definition: ServerSocket.h:45
#define UTL_CLASS_DECL_ABC(DC, BC)
Declaration of standard UTL++ functionality for an abstract base class (ABC).
Definition: macros.h:650
#define UTL_CLASS_NO_COPY
Declare that a class cannot do copy().
Definition: macros.h:358
Stream with file descriptor.
Definition: FDstream.h:35
Root of UTL++ class hierarchy.
Definition: Object.h:52
int compare(bool lhs, bool rhs)
Compare two boolean values.
void init()
Initialize UTL++.
Internet host address.