blob: a4f4d62f4509319eb1d1254a201ae98c2b7f8cb5 [file] [log] [blame]
The Android Open Source Project52d4c302009-03-03 19:29:09 -08001//
2// Copyright 2005 The Android Open Source Project
3//
4// Create or attach to a named bi-directional channel on the local machine.
5//
6#ifndef __LIBS_LOCALBICHANNEL_H
7#define __LIBS_LOCALBICHANNEL_H
8
9#ifdef HAVE_ANDROID_OS
10#error DO NOT USE THIS FILE IN THE DEVICE BUILD
11#endif
12
Jean-Baptiste Queru2c8ead32009-11-12 18:45:17 -080013#include "Pipe.h"
The Android Open Source Project52d4c302009-03-03 19:29:09 -080014
15namespace android {
16
17/*
18 * This is essentially a wrapper class for UNIX-domain sockets. The
19 * idea is to set one up with create() or attach to one with attach()
20 * and then extract the unidirectional read/write Pipes. These can
21 * be used directly or stuffed into a MessageStream.
22 *
23 * The name for the pipe should be a short filename made up of alphanumeric
24 * characters. Depending on the implementation, we may create a file in
25 * /tmp with the specified name, removing any existing copy.
26 */
27class LocalBiChannel {
28public:
29 LocalBiChannel(void);
30 ~LocalBiChannel(void);
31
32 /* create the "listen" side */
33 bool create(const char* name);
34
35 /*
36 * Listen for a connection. When we get one, we create unidirectional
37 * read/write pipes and return them.
38 */
39 bool listen(Pipe** ppReadPipe, Pipe** ppWritePipe);
40
41 /*
42 * Attach to a channel created by somebody else. Returns pipes.
43 */
44 bool attach(const char* name, Pipe** ppReadPipe, Pipe** ppWritePipe);
45
46private:
47 char* mFileName;
48 bool mIsListener;
49 unsigned long mHandle;
50};
51
52}; // namespace android
53
54#endif // __LIBS_LOCALBICHANNEL_H