emulator: opengl: Add support for unix sockets.
This patch allows the OpenGLES rendering library to use Unix sockets instead of TCP ones when communicating with its clients. On certain benchmarks (e.g. 0xBench teapot), this provides a noticeable improvement (x1.05 fps) without any other changes. On practice, Unix sockets are faster than TCP sockets, even local ones. Also, this introduces a moderate amount of abstraction that will allow us to use Win32 named pipes on Windows (where TCP sockets are much slower than they are on Unix). Note that by default, TCP streams are still used. The client (emulator) must call the new API 'setStreamMode' to change it to STREAM_MODE_UNIX between 'initLibrary' and 'startOpenglRenderer' calls. + Adjust callers / user appropriately. Change-Id: I4105bbf07541f3146b50a58d1a5b51e8cf044fab
This commit is contained in:
@@ -3,16 +3,23 @@
|
||||
#
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
### CodecCommon guest ##############################################
|
||||
$(call emugl-begin-static-library,libOpenglCodecCommon)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
commonSources := \
|
||||
GLClientState.cpp \
|
||||
GLSharedGroup.cpp \
|
||||
glUtils.cpp \
|
||||
SocketStream.cpp \
|
||||
TcpStream.cpp \
|
||||
TimeUtils.cpp
|
||||
|
||||
ifneq ($(HOST_OS),windows)
|
||||
commonSources += UnixStream.cpp
|
||||
endif
|
||||
|
||||
### CodecCommon guest ##############################################
|
||||
$(call emugl-begin-static-library,libOpenglCodecCommon)
|
||||
|
||||
LOCAL_SRC_FILES := $(commonSources)
|
||||
|
||||
LOCAL_CFLAGS += -DLOG_TAG=\"eglCodecCommon\"
|
||||
|
||||
$(call emugl-export,SHARED_LIBRARIES,libcutils libutils)
|
||||
@@ -22,11 +29,7 @@ $(call emugl-end-module)
|
||||
### OpenglCodecCommon host ##############################################
|
||||
$(call emugl-begin-host-static-library,libOpenglCodecCommon)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
GLClientState.cpp \
|
||||
glUtils.cpp \
|
||||
TcpStream.cpp \
|
||||
TimeUtils.cpp
|
||||
LOCAL_SRC_FILES := $(commonSources)
|
||||
|
||||
$(call emugl-export,STATIC_LIBRARIES,libcutils)
|
||||
$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
|
||||
|
||||
163
tools/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp
Normal file
163
tools/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "SocketStream.h"
|
||||
#include <cutils/sockets.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/un.h>
|
||||
#else
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
SocketStream::SocketStream(size_t bufSize) :
|
||||
IOStream(bufSize),
|
||||
m_sock(-1),
|
||||
m_bufsize(bufSize),
|
||||
m_buf(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
SocketStream::SocketStream(int sock, size_t bufSize) :
|
||||
IOStream(bufSize),
|
||||
m_sock(sock),
|
||||
m_bufsize(bufSize),
|
||||
m_buf(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
SocketStream::~SocketStream()
|
||||
{
|
||||
if (m_sock >= 0) {
|
||||
#ifdef _WIN32
|
||||
closesocket(m_sock);
|
||||
#else
|
||||
::close(m_sock);
|
||||
#endif
|
||||
}
|
||||
if (m_buf != NULL) {
|
||||
free(m_buf);
|
||||
m_buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void *SocketStream::allocBuffer(size_t minSize)
|
||||
{
|
||||
size_t allocSize = (m_bufsize < minSize ? minSize : m_bufsize);
|
||||
if (!m_buf) {
|
||||
m_buf = (unsigned char *)malloc(allocSize);
|
||||
}
|
||||
else if (m_bufsize < allocSize) {
|
||||
unsigned char *p = (unsigned char *)realloc(m_buf, allocSize);
|
||||
if (p != NULL) {
|
||||
m_buf = p;
|
||||
m_bufsize = allocSize;
|
||||
} else {
|
||||
ERR("%s: realloc (%d) failed\n", __FUNCTION__, allocSize);
|
||||
free(m_buf);
|
||||
m_buf = NULL;
|
||||
m_bufsize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return m_buf;
|
||||
};
|
||||
|
||||
int SocketStream::commitBuffer(size_t size)
|
||||
{
|
||||
if (!valid()) return -1;
|
||||
|
||||
size_t res = size;
|
||||
int retval = 0;
|
||||
|
||||
while (res > 0) {
|
||||
ssize_t stat = ::send(m_sock, (const char *)(m_buf) + (size - res), res, 0);
|
||||
if (stat < 0) {
|
||||
if (errno != EINTR) {
|
||||
retval = stat;
|
||||
ERR("%s: failed: %s\n", __FUNCTION__, strerror(errno));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
res -= stat;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
const unsigned char *SocketStream::readFully(void *buf, size_t len)
|
||||
{
|
||||
const unsigned char* ret = NULL;
|
||||
if (!valid()) return NULL;
|
||||
if (!buf) {
|
||||
return NULL; // do not allow NULL buf in that implementation
|
||||
}
|
||||
size_t res = len;
|
||||
while (res > 0) {
|
||||
ssize_t stat = ::recv(m_sock, (char *)(buf) + len - res, res, 0);
|
||||
if (stat > 0) {
|
||||
res -= stat;
|
||||
continue;
|
||||
}
|
||||
if (stat == 0 || errno != EINTR) { // client shutdown or error
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return (const unsigned char *)buf;
|
||||
}
|
||||
|
||||
const unsigned char *SocketStream::read( void *buf, size_t *inout_len)
|
||||
{
|
||||
if (!valid()) return NULL;
|
||||
if (!buf) {
|
||||
return NULL; // do not allow NULL buf in that implementation
|
||||
}
|
||||
|
||||
int n;
|
||||
do {
|
||||
n = recv(buf, *inout_len);
|
||||
} while( n < 0 && errno == EINTR );
|
||||
|
||||
if (n > 0) {
|
||||
*inout_len = n;
|
||||
return (const unsigned char *)buf;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int SocketStream::recv(void *buf, size_t len)
|
||||
{
|
||||
if (!valid()) return int(ERR_INVALID_SOCKET);
|
||||
int res = 0;
|
||||
while(true) {
|
||||
res = ::recv(m_sock, (char *)buf, len, 0);
|
||||
if (res < 0) {
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __SOCKET_STREAM_H
|
||||
#define __SOCKET_STREAM_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "IOStream.h"
|
||||
|
||||
class SocketStream : public IOStream {
|
||||
public:
|
||||
typedef enum { ERR_INVALID_SOCKET = -1000 } SocketStreamError;
|
||||
|
||||
explicit SocketStream(size_t bufsize = 10000);
|
||||
virtual ~SocketStream();
|
||||
|
||||
virtual int listen(unsigned short port) = 0;
|
||||
virtual SocketStream *accept() = 0;
|
||||
virtual int connect(unsigned short port) = 0;
|
||||
|
||||
virtual void *allocBuffer(size_t minSize);
|
||||
virtual int commitBuffer(size_t size);
|
||||
virtual const unsigned char *readFully(void *buf, size_t len);
|
||||
virtual const unsigned char *read(void *buf, size_t *inout_len);
|
||||
|
||||
bool valid() { return m_sock >= 0; }
|
||||
virtual int recv(void *buf, size_t len);
|
||||
|
||||
protected:
|
||||
int m_sock;
|
||||
size_t m_bufsize;
|
||||
unsigned char *m_buf;
|
||||
|
||||
SocketStream(int sock, size_t bufSize);
|
||||
int writeFully(const void *buf, size_t len);
|
||||
};
|
||||
|
||||
#endif /* __SOCKET_STREAM_H */
|
||||
@@ -29,18 +29,12 @@
|
||||
#endif
|
||||
|
||||
TcpStream::TcpStream(size_t bufSize) :
|
||||
IOStream(bufSize),
|
||||
m_sock(-1),
|
||||
m_bufsize(bufSize),
|
||||
m_buf(NULL)
|
||||
SocketStream(bufSize)
|
||||
{
|
||||
}
|
||||
|
||||
TcpStream::TcpStream(int sock, size_t bufSize) :
|
||||
IOStream(bufSize),
|
||||
m_sock(sock),
|
||||
m_bufsize(bufSize),
|
||||
m_buf(NULL)
|
||||
SocketStream(sock, bufSize)
|
||||
{
|
||||
// disable Nagle algorithm to improve bandwidth of small
|
||||
// packets which are quite common in our implementation.
|
||||
@@ -53,34 +47,15 @@ TcpStream::TcpStream(int sock, size_t bufSize) :
|
||||
setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, (const char*)&flag, sizeof(flag) );
|
||||
}
|
||||
|
||||
TcpStream::~TcpStream()
|
||||
int TcpStream::listen(unsigned short port)
|
||||
{
|
||||
if (m_sock >= 0) {
|
||||
#ifdef _WIN32
|
||||
closesocket(m_sock);
|
||||
#else
|
||||
::close(m_sock);
|
||||
#endif
|
||||
}
|
||||
if (m_buf != NULL) {
|
||||
free(m_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int TcpStream::listen(unsigned short port, bool localhost_only)
|
||||
{
|
||||
if (localhost_only) {
|
||||
m_sock = socket_loopback_server(port, SOCK_STREAM);
|
||||
} else {
|
||||
m_sock = socket_inaddr_any_server(port, SOCK_STREAM);
|
||||
}
|
||||
m_sock = socket_loopback_server(port, SOCK_STREAM);
|
||||
if (!valid()) return int(ERR_INVALID_SOCKET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TcpStream * TcpStream::accept()
|
||||
SocketStream * TcpStream::accept()
|
||||
{
|
||||
int clientSock = -1;
|
||||
|
||||
@@ -103,120 +78,14 @@ TcpStream * TcpStream::accept()
|
||||
return clientStream;
|
||||
}
|
||||
|
||||
int TcpStream::connect(unsigned short port)
|
||||
{
|
||||
return connect("127.0.0.1",port);
|
||||
}
|
||||
|
||||
int TcpStream::connect(const char *hostname, unsigned short port)
|
||||
int TcpStream::connect(const char* hostname, unsigned short port)
|
||||
{
|
||||
m_sock = socket_network_client(hostname, port, SOCK_STREAM);
|
||||
if (!valid()) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *TcpStream::allocBuffer(size_t minSize)
|
||||
{
|
||||
size_t allocSize = (m_bufsize < minSize ? minSize : m_bufsize);
|
||||
if (!m_buf) {
|
||||
m_buf = (unsigned char *)malloc(allocSize);
|
||||
}
|
||||
else if (m_bufsize < allocSize) {
|
||||
unsigned char *p = (unsigned char *)realloc(m_buf, allocSize);
|
||||
if (p != NULL) {
|
||||
m_buf = p;
|
||||
m_bufsize = allocSize;
|
||||
} else {
|
||||
ERR("realloc (%d) failed\n", allocSize);
|
||||
free(m_buf);
|
||||
m_buf = NULL;
|
||||
m_bufsize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return m_buf;
|
||||
};
|
||||
|
||||
int TcpStream::commitBuffer(size_t size)
|
||||
{
|
||||
return writeFully(m_buf, size);
|
||||
}
|
||||
|
||||
int TcpStream::writeFully(const void *buf, size_t len)
|
||||
{
|
||||
if (!valid()) return -1;
|
||||
|
||||
size_t res = len;
|
||||
int retval = 0;
|
||||
|
||||
while (res > 0) {
|
||||
ssize_t stat = ::send(m_sock, (const char *)(buf) + (len - res), res, 0);
|
||||
if (stat < 0) {
|
||||
if (errno != EINTR) {
|
||||
retval = stat;
|
||||
ERR("TcpStream::writeFully failed: %s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
res -= stat;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
const unsigned char *TcpStream::readFully(void *buf, size_t len)
|
||||
{
|
||||
if (!valid()) return NULL;
|
||||
if (!buf) {
|
||||
return NULL; // do not allow NULL buf in that implementation
|
||||
}
|
||||
size_t res = len;
|
||||
while (res > 0) {
|
||||
ssize_t stat = ::recv(m_sock, (char *)(buf) + len - res, res, 0);
|
||||
if (stat == 0) {
|
||||
// client shutdown;
|
||||
return NULL;
|
||||
} else if (stat < 0) {
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
res -= stat;
|
||||
}
|
||||
}
|
||||
return (const unsigned char *)buf;
|
||||
}
|
||||
|
||||
const unsigned char *TcpStream::read( void *buf, size_t *inout_len)
|
||||
{
|
||||
if (!valid()) return NULL;
|
||||
if (!buf) {
|
||||
return NULL; // do not allow NULL buf in that implementation
|
||||
}
|
||||
|
||||
int n;
|
||||
do {
|
||||
n = recv(buf, *inout_len);
|
||||
} while( n < 0 && errno == EINTR );
|
||||
|
||||
if (n > 0) {
|
||||
*inout_len = n;
|
||||
return (const unsigned char *)buf;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int TcpStream::recv(void *buf, size_t len)
|
||||
{
|
||||
if (!valid()) return int(ERR_INVALID_SOCKET);
|
||||
int res = 0;
|
||||
while(true) {
|
||||
res = ::recv(m_sock, (char *)buf, len, 0);
|
||||
if (res < 0) {
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -16,35 +16,16 @@
|
||||
#ifndef __TCP_STREAM_H
|
||||
#define __TCP_STREAM_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "IOStream.h"
|
||||
#include "SocketStream.h"
|
||||
|
||||
|
||||
class TcpStream : public IOStream {
|
||||
class TcpStream : public SocketStream {
|
||||
public:
|
||||
typedef enum { ERR_INVALID_SOCKET = -1000 } TcpStreamError;
|
||||
|
||||
explicit TcpStream(size_t bufsize = 10000);
|
||||
~TcpStream();
|
||||
int listen(unsigned short port, bool localhost_only = true);
|
||||
TcpStream *accept();
|
||||
int connect(const char *hostname, unsigned short port);
|
||||
|
||||
virtual void *allocBuffer(size_t minSize);
|
||||
virtual int commitBuffer(size_t size);
|
||||
virtual const unsigned char *readFully( void *buf, size_t len);
|
||||
virtual const unsigned char *read( void *buf, size_t *inout_len);
|
||||
|
||||
bool valid() { return m_sock >= 0; }
|
||||
int recv(void *buf, size_t len);
|
||||
|
||||
virtual int listen(unsigned short port);
|
||||
virtual SocketStream *accept();
|
||||
virtual int connect(unsigned short port);
|
||||
int connect(const char* hostname, unsigned short port);
|
||||
private:
|
||||
int writeFully(const void *buf, size_t len);
|
||||
|
||||
private:
|
||||
int m_sock;
|
||||
size_t m_bufsize;
|
||||
unsigned char *m_buf;
|
||||
TcpStream(int sock, size_t bufSize);
|
||||
};
|
||||
|
||||
|
||||
137
tools/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp
Normal file
137
tools/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "UnixStream.h"
|
||||
#include <cutils/sockets.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* Not all systems define PATH_MAX, those who don't generally don't
|
||||
* have a limit on the maximum path size, so use a value that is
|
||||
* large enough for our very limited needs.
|
||||
*/
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 128
|
||||
#endif
|
||||
|
||||
UnixStream::UnixStream(size_t bufSize) :
|
||||
SocketStream(bufSize)
|
||||
{
|
||||
}
|
||||
|
||||
UnixStream::UnixStream(int sock, size_t bufSize) :
|
||||
SocketStream(sock, bufSize)
|
||||
{
|
||||
}
|
||||
|
||||
/* Initialize a sockaddr_un with the appropriate values corresponding
|
||||
* to a given 'virtual port'. Returns 0 on success, -1 on error.
|
||||
*/
|
||||
static int
|
||||
make_unix_path(char *path, size_t pathlen, int port_number)
|
||||
{
|
||||
char tmp[PATH_MAX]; // temp directory
|
||||
int ret = 0;
|
||||
|
||||
// First, create user-specific temp directory if needed
|
||||
const char* user = getenv("USER");
|
||||
if (user != NULL) {
|
||||
struct stat st;
|
||||
snprintf(tmp, sizeof(tmp), "/tmp/android-%s", user);
|
||||
do {
|
||||
ret = ::lstat(tmp, &st);
|
||||
} while (ret < 0 && errno == EINTR);
|
||||
|
||||
if (ret < 0 && errno == ENOENT) {
|
||||
do {
|
||||
ret = ::mkdir(tmp, 0766);
|
||||
} while (ret < 0 && errno == EINTR);
|
||||
if (ret < 0) {
|
||||
ERR("Could not create temp directory: %s", tmp);
|
||||
user = NULL; // will fall-back to /tmp
|
||||
}
|
||||
}
|
||||
else if (ret < 0) {
|
||||
user = NULL; // will fallback to /tmp
|
||||
}
|
||||
}
|
||||
|
||||
if (user == NULL) { // fallback to /tmp in case of error
|
||||
snprintf(tmp, sizeof(tmp), "/tmp");
|
||||
}
|
||||
|
||||
// Now, initialize it properly
|
||||
snprintf(path, pathlen, "%s/qemu-gles-%d", tmp, port_number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int UnixStream::listen(unsigned short port)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (make_unix_path(path, sizeof(path), port) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_sock = socket_local_server(path, ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM);
|
||||
if (!valid()) return int(ERR_INVALID_SOCKET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SocketStream * UnixStream::accept()
|
||||
{
|
||||
int clientSock = -1;
|
||||
|
||||
while (true) {
|
||||
struct sockaddr_un addr;
|
||||
socklen_t len = sizeof(addr);
|
||||
clientSock = ::accept(m_sock, (sockaddr *)&addr, &len);
|
||||
|
||||
if (clientSock < 0 && errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
UnixStream *clientStream = NULL;
|
||||
|
||||
if (clientSock >= 0) {
|
||||
clientStream = new UnixStream(clientSock, m_bufsize);
|
||||
}
|
||||
return clientStream;
|
||||
}
|
||||
|
||||
int UnixStream::connect(unsigned short port)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (make_unix_path(path, sizeof(path), port) < 0)
|
||||
return -1;
|
||||
|
||||
m_sock = socket_local_client(path, ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM);
|
||||
if (!valid()) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
31
tools/emulator/opengl/shared/OpenglCodecCommon/UnixStream.h
Normal file
31
tools/emulator/opengl/shared/OpenglCodecCommon/UnixStream.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __UNIX_STREAM_H
|
||||
#define __UNIX_STREAM_H
|
||||
|
||||
#include "SocketStream.h"
|
||||
|
||||
class UnixStream : public SocketStream {
|
||||
public:
|
||||
explicit UnixStream(size_t bufsize = 10000);
|
||||
virtual int listen(unsigned short port);
|
||||
virtual SocketStream *accept();
|
||||
virtual int connect(unsigned short port);
|
||||
private:
|
||||
UnixStream(int sock, size_t bufSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user