]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/arm-ds5-gator.git/blob - daemon/OlySocket.h
gator: Version 5.18
[android-sdk/arm-ds5-gator.git] / daemon / OlySocket.h
1 /**
2  * Copyright (C) ARM Limited 2010-2014. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
9 #ifndef __OLY_SOCKET_H__
10 #define __OLY_SOCKET_H__
12 class OlySocket {
13 public:
14   OlySocket(int port, const char* hostname);
15   OlySocket(int socketID);
16 #ifndef WIN32
17   OlySocket(const char* path);
18 #endif
19   ~OlySocket();
21   void closeSocket();
22   void shutdownConnection();
23   void send(const char* buffer, int size);
24   int receive(char* buffer, int size);
25   int receiveNBytes(char* buffer, int size);
26   int receiveString(char* buffer, int size);
28   bool isValid() const { return mSocketID >= 0; }
30 private:
31   int mSocketID;
33   void createClientSocket(const char* hostname, int port);
34 };
36 class OlyServerSocket {
37 public:
38   OlyServerSocket(int port);
39 #ifndef WIN32
40   OlyServerSocket(const char* path);
41 #endif
42   ~OlyServerSocket();
44   int acceptConnection();
45   void closeServerSocket();
47 private:
48   int mFDServer;
50   void createServerSocket(int port);
51 };
53 #endif //__OLY_SOCKET_H__