From 8e4bff4cab0ddac6060645b0715210484d02ff40 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Wed, 30 Aug 2017 08:25:59 +0000 Subject: Initial file dump from open source release --- tools/gator/daemon/OlySocket.h | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tools/gator/daemon/OlySocket.h (limited to 'tools/gator/daemon/OlySocket.h') diff --git a/tools/gator/daemon/OlySocket.h b/tools/gator/daemon/OlySocket.h new file mode 100644 index 00000000..6b53b01f --- /dev/null +++ b/tools/gator/daemon/OlySocket.h @@ -0,0 +1,64 @@ +/** + * Copyright (C) ARM Limited 2010-2014. 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 + +#ifdef WIN32 +typedef socklen_t int; +#else +#include +#endif + +class OlySocket { +public: +#ifndef WIN32 + static int connect(const char* path, const size_t pathSize); +#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); +#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__ -- cgit v1.3.1