Free Electron
SocketHandler.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __netsignal_SocketHandler_h__
8 #define __netsignal_SocketHandler_h__
9 namespace fe
10 {
11 namespace ext
12 {
13 
14 /** Socket handler
15 
16  @copydoc SocketHandler_info
17  */
19  virtual public HandlerI
20 {
21  public:
22  SocketHandler(SockAddr server_addr,
23  Socket::Transport transport=Socket::e_tcp,
24  String ioPriority="normal");
25 virtual ~SocketHandler(void);
26 
27 virtual void handle(Record &signal);
28 virtual void handleBind(sp<SignalerI> spSignalerI, sp<Layout> spLayout);
29 
30 virtual void addSenderLayout(sp<Layout> spLayout);
31 
32  enum
33  {
34  e_end_op = 0,
35  e_create_signal_sender = 1,
36  e_create_signal_receiver = 2
37  };
38 
39  struct SenderUndoStruct
40  {
41  sp<HandlerI> m_spSignalSender;
42  sp<ChunkSender> m_spChunkSender;
43  std::list<sp<Layout> > m_layouts;
44  };
45 
46  struct ReceiverUndoStruct
47  {
48  sp<HandlerI> m_spSignalReceiver;
49  sp<ChunkReceiver> m_spChunkReceiver;
50  };
51 
52  private:
53  void createSignalSender(sp<Socket> spSocket);
54  void createSignalReceiver(sp<Socket> spSocket);
55  void stop(void);
56  void assertScope(sp<Scope> spScope);
57  void cleanDeadConnections(void);
58 
59  private:
60  sp<SocketSpool> m_spSocketSpool;
61  SockAddr m_serverAddr;
62  Socket::Transport m_sockTransportType;
63  String m_ioPriority;
64  sp<SignalerI> m_spSignaler;
65  sp<Scope> m_spScope;
66  sp<Layout> m_spLayout;
67  sp<Listener> m_spListener;
68  std::list<sp<Layout> > m_layouts;
69  std::list<SenderUndoStruct> m_senders;
70  std::list<ReceiverUndoStruct> m_receivers;
71 };
72 
73 } /* namespace ext */
74 } /* namespace fe */
75 
76 
77 #endif /* __netsignal_SocketHandler_h__ */
kernel
Definition: namespace.dox:3
BSD socket address wrapper.
Definition: Socket.h:17
Socket handler.
Definition: SocketHandler.h:18
Interface to handle signals from an SignalerI.
Definition: HandlerI.h:22
Automatically reference-counted string container.
Definition: String.h:128
Reference to an instance of a Layout.
Definition: RecordSB.h:35