SocketClient.h revision 8c5669f9f9a228efebf4059fd4ceace5cece578b
1#ifndef _SOCKET_CLIENT_H 2#define _SOCKET_CLIENT_H 3 4#include "../../../frameworks/base/include/utils/List.h" 5 6#include <pthread.h> 7#include <sys/types.h> 8 9class SocketClient { 10 int mSocket; 11 pthread_mutex_t mWriteMutex; 12 13 /* Peer process ID */ 14 pid_t mPid; 15 16 /* Peer user ID */ 17 uid_t mUid; 18 19 /* Peer group ID */ 20 gid_t mGid; 21 22public: 23 SocketClient(int sock); 24 virtual ~SocketClient() {} 25 26 int getSocket() { return mSocket; } 27 pid_t getPid() const { return mPid; } 28 uid_t getUid() const { return mUid; } 29 gid_t getGid() const { return mGid; } 30 31 // Send null-terminated C strings: 32 int sendMsg(int code, const char *msg, bool addErrno); 33 int sendMsg(const char *msg); 34 35 // Sending binary data: 36 int sendData(const void *data, int len); 37}; 38 39typedef android::List<SocketClient *> SocketClientCollection; 40#endif 41