Jon Medhurst | aaf37a3 | 2013-06-11 12:10:56 +0100 | [diff] [blame^] | 1 | /** |
| 2 | * Copyright (C) ARM Limited 2010-2013. 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 | */ |
| 8 | |
| 9 | #ifndef __OLY_SOCKET_H__ |
| 10 | #define __OLY_SOCKET_H__ |
| 11 | |
| 12 | #include <string.h> |
| 13 | |
| 14 | class OlySocket { |
| 15 | public: |
| 16 | OlySocket(int port, bool multipleConnections = false); |
| 17 | OlySocket(int port, char* hostname); |
| 18 | ~OlySocket(); |
| 19 | int acceptConnection(); |
| 20 | void closeSocket(); |
| 21 | void closeServerSocket(); |
| 22 | void shutdownConnection(); |
| 23 | void send(char* buffer, int size); |
| 24 | void sendString(const char* string) {send((char*)string, strlen(string));} |
| 25 | int receive(char* buffer, int size); |
| 26 | int receiveNBytes(char* buffer, int size); |
| 27 | int receiveString(char* buffer, int size); |
| 28 | int getSocketID() {return mSocketID;} |
| 29 | private: |
| 30 | int mSocketID, mFDServer; |
| 31 | void createClientSocket(char* hostname, int port); |
| 32 | void createSingleServerConnection(int port); |
| 33 | void createServerSocket(int port); |
| 34 | }; |
| 35 | |
| 36 | #endif //__OLY_SOCKET_H__ |