]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Port.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / ipc / Port.h
1 /*
2 * $Id$
3 *
4 * DEBUG: section 54 Interprocess Communication
5 *
6 */
7
8 #ifndef SQUID_IPC_PORT_H
9 #define SQUID_IPC_PORT_H
10
11 #include "SquidString.h"
12 #include "ipc/UdsOp.h"
13
14 namespace Ipc
15 {
16
17 /// Waits for and receives incoming IPC messages; kids handle the messages
18 class Port: public UdsOp
19 {
20 public:
21 Port(const String &aListenAddr);
22 /// calculates IPC message address for strand #id at path
23 static String MakeAddr(const char *path, int id);
24
25 protected:
26 virtual void start() = 0; // UdsOp (AsyncJob) API; has body
27 virtual bool doneAll() const; // UdsOp (AsyncJob) API
28
29 /// read the next incoming message
30 void listen();
31
32 /// handle IPC message just read
33 virtual void receive(const TypedMsgHdr& message) = 0;
34
35 private:
36 void noteRead(const CommIoCbParams &params); // Comm callback API
37
38 private:
39 TypedMsgHdr buf; ///< msghdr struct filled by Comm
40 };
41
42 extern const char coordinatorAddr[]; ///< where coordinator listens
43 extern const char strandAddrPfx[]; ///< strand's listening address prefix
44
45 } // namespace Ipc
46
47 #endif /* SQUID_IPC_PORT_H */