blob: 6b53b01fc3ee6e6c9221e219f26aca43a28882a9 [file] [log] [blame]
* 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 <stddef.h>
#ifdef WIN32
typedef socklen_t int;
#include <sys/socket.h>
class OlySocket {
#ifndef WIN32
static int connect(const char* path, const size_t pathSize);
OlySocket(int socketID);
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; }
int mSocketID;
class OlyServerSocket {
OlyServerSocket(int port);
#ifndef WIN32
OlyServerSocket(const char* path, const size_t pathSize);
int acceptConnection();
void closeServerSocket();
int getFd() { return mFDServer; }
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__