diff options
Diffstat (limited to 'include/sysutils')
-rw-r--r-- | include/sysutils/SocketClient.h | 15 | ||||
-rw-r--r-- | include/sysutils/SocketListener.h | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/include/sysutils/SocketClient.h b/include/sysutils/SocketClient.h index e7fb177..d6bb7d5 100644 --- a/include/sysutils/SocketClient.h +++ b/include/sysutils/SocketClient.h @@ -19,6 +19,10 @@ class SocketClient { /* Peer group ID */ gid_t mGid; + /* Reference count (starts at 1) */ + pthread_mutex_t mRefCountMutex; + int mRefCount; + public: SocketClient(int sock); virtual ~SocketClient() {} @@ -28,8 +32,19 @@ public: uid_t getUid() const { return mUid; } gid_t getGid() const { return mGid; } + // Send null-terminated C strings: int sendMsg(int code, const char *msg, bool addErrno); int sendMsg(const char *msg); + + // Sending binary data: + int sendData(const void *data, int len); + + // Optional reference counting. Reference count starts at 1. If + // it's decremented to 0, it deletes itself. + // SocketListener creates a SocketClient (at refcount 1) and calls + // decRef() when it's done with the client. + void incRef(); + bool decRef(); // returns true at 0 (but note: SocketClient already deleted) }; typedef android::List<SocketClient *> SocketClientCollection; diff --git a/include/sysutils/SocketListener.h b/include/sysutils/SocketListener.h index c7edfeb..6592b01 100644 --- a/include/sysutils/SocketListener.h +++ b/include/sysutils/SocketListener.h @@ -30,7 +30,7 @@ class SocketListener { pthread_t mThread; public: - SocketListener(const char *socketNames, bool listen); + SocketListener(const char *socketName, bool listen); SocketListener(int socketFd, bool listen); virtual ~SocketListener(); |