2 * Copyright (C) ARM Limited 2010-2014. All rights reserved.
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.
9 #ifndef __OLY_SOCKET_H__
10 #define __OLY_SOCKET_H__
15 typedef socklen_t int;
17 #include <sys/socket.h>
23 static int connect(const char* path, const size_t pathSize);
26 OlySocket(int socketID);
30 void shutdownConnection();
31 void send(const char* buffer, int size);
32 int receive(char* buffer, int size);
33 int receiveNBytes(char* buffer, int size);
34 int receiveString(char* buffer, int size);
36 bool isValid() const { return mSocketID >= 0; }
42 class OlyServerSocket {
44 OlyServerSocket(int port);
46 OlyServerSocket(const char* path, const size_t pathSize);
50 int acceptConnection();
51 void closeServerSocket();
53 int getFd() { return mFDServer; }
58 void createServerSocket(int port);
61 int socket_cloexec(int domain, int type, int protocol);
62 int accept_cloexec(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
64 #endif //__OLY_SOCKET_H__