diff options
author | Jon Medhurst <tixy@linaro.org> | 2015-09-14 11:39:53 +0100 |
---|---|---|
committer | Jon Medhurst <tixy@linaro.org> | 2015-09-14 11:39:53 +0100 |
commit | 4d35f06f9c3c0c807d3bc71141b116a2ae602343 (patch) | |
tree | 95764103e9331f243431709b907d7915ac069ffe /tools/gator/daemon/OlySocket.h | |
parent | 771c49e2ba7daa47aebb87184b5dc7bcdfb59a5a (diff) | |
parent | f5bdd6b7426dfbab2003c0986545c8e34f5d9d63 (diff) |
Merge branch 'lsk-3.18-armlt-gator' into integration-lsk-3.18-armlt-android
Conflicts:
drivers/Makefile
Diffstat (limited to 'tools/gator/daemon/OlySocket.h')
-rw-r--r-- | tools/gator/daemon/OlySocket.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tools/gator/daemon/OlySocket.h b/tools/gator/daemon/OlySocket.h new file mode 100644 index 00000000000..757a2522f92 --- /dev/null +++ b/tools/gator/daemon/OlySocket.h @@ -0,0 +1,64 @@ +/** + * Copyright (C) ARM Limited 2010-2015. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __OLY_SOCKET_H__ +#define __OLY_SOCKET_H__ + +#include <stddef.h> + +#ifdef WIN32 +typedef int socklen_t; +#else +#include <sys/socket.h> +#endif + +class OlySocket { +public: +#ifndef WIN32 + static int connect(const char* path, const size_t pathSize, const bool calculateAddrlen = false); +#endif + + OlySocket(int socketID); + ~OlySocket(); + + void closeSocket(); + void shutdownConnection(); + void send(const char* buffer, int size); + int receive(char* buffer, int size); + int receiveNBytes(char* buffer, int size); + int receiveString(char* buffer, int size); + + bool isValid() const { return mSocketID >= 0; } + +private: + int mSocketID; +}; + +class OlyServerSocket { +public: + OlyServerSocket(int port); +#ifndef WIN32 + OlyServerSocket(const char* path, const size_t pathSize, const bool calculateAddrlen = false); +#endif + ~OlyServerSocket(); + + int acceptConnection(); + void closeServerSocket(); + + int getFd() { return mFDServer; } + +private: + int mFDServer; + + void createServerSocket(int port); +}; + +int socket_cloexec(int domain, int type, int protocol); +int accept_cloexec(int sockfd, struct sockaddr *addr, socklen_t *addrlen); + +#endif //__OLY_SOCKET_H__ |