Brief description of class still missing. More...
#include <UnixClientStream.h>
Public Member Functions | |
DynamicBuffer * | buffer () const |
virtual bool | connect () |
virtual void | event (short type) |
virtual short | eventTypes () |
virtual void | hungUp () |
UnixClientStream (int fileDescriptor, const char *peer) | |
UnixClientStream (const char *peer) | |
int | write (const char *bytes, int byteCount) const |
virtual | ~UnixClientStream () |
Static Public Member Functions | |
static void | setAddress (sockaddr_un &addr, const char *peer) |
Protected Member Functions | |
void | setBuffer (DynamicBuffer *buffer) |
Brief description of class still missing.
Full description of class still missing
GpCoreTools::UnixClientStream::UnixClientStream | ( | int | fileDescriptor, |
const char * | peer | ||
) |
Description of constructor still missing
References setAddress(), GpCoreTools::Stream::setFileDescriptor(), and TRACE.
: Stream() { TRACE; setFileDescriptor(fileDescriptor); setAddress(_peer, peer); _buffer=0; }
GpCoreTools::UnixClientStream::UnixClientStream | ( | const char * | peer | ) |
Description of constructor still missing
References GpCoreTools::Stream::fileDescriptor(), setAddress(), GpCoreTools::Stream::setFileDescriptor(), TRACE, and write().
: Stream() { TRACE; setFileDescriptor(socket(AF_UNIX, SOCK_STREAM, 0)); if(fileDescriptor()<=0) { Log::write(0, "%s\n", strerror(errno)); } setAddress(_peer, peer); _buffer=0; }
GpCoreTools::UnixClientStream::~UnixClientStream | ( | ) | [virtual] |
DynamicBuffer* GpCoreTools::UnixClientStream::buffer | ( | ) | const [inline] |
{return _buffer;}
bool GpCoreTools::UnixClientStream::connect | ( | ) | [virtual] |
References GpCoreTools::Stream::fileDescriptor(), TRACE, and write().
{ TRACE; Log::write(1, "connecting to %s\n", _peer.sun_path); if(::connect(fileDescriptor(), (sockaddr *)&_peer, sizeof(sockaddr_un))<0) { Log::write(1, "%s\n", strerror(errno)); return false; } else { Log::write(1, "connected to %s\n", _peer.sun_path); return true; } }
void GpCoreTools::UnixClientStream::event | ( | short | type | ) | [virtual] |
Implements GpCoreTools::Stream.
References GpCoreTools::Stream::close(), GpCoreTools::Stream::fileDescriptor(), hungUp(), GpCoreTools::DynamicBuffer::read(), TRACE, and write().
{ TRACE; if(type & POLLIN) { if(!_buffer->read()) { Log::write(1, "error reading data (socket %i)\n", fileDescriptor()); } } if(type & POLLRDHUP) { Log::write(1, "connection hung up with %s (%i)\n", _peer.sun_path, fileDescriptor()); close(); hungUp(); } }
virtual short GpCoreTools::UnixClientStream::eventTypes | ( | ) | [inline, virtual] |
Implements GpCoreTools::Stream.
{return POLLIN | POLLRDHUP;}
virtual void GpCoreTools::UnixClientStream::hungUp | ( | ) | [inline, virtual] |
Referenced by event().
{}
void GpCoreTools::UnixClientStream::setAddress | ( | sockaddr_un & | addr, |
const char * | peer | ||
) | [static] |
Referenced by GpCoreTools::UnixServerStream::listen(), and UnixClientStream().
{
addr.sun_family=AF_UNIX;
assert(strlen(peer)<=108-1);
//memset(addr.sun_path, 108*sizeof(char), 0);
strcpy(addr.sun_path, peer);
}
void GpCoreTools::UnixClientStream::setBuffer | ( | DynamicBuffer * | buffer | ) | [inline, protected] |
{_buffer=buffer;}
int GpCoreTools::UnixClientStream::write | ( | const char * | bytes, |
int | byteCount | ||
) | const [inline] |
Referenced by connect(), event(), and UnixClientStream().
{ return ::write(fileDescriptor(), bytes, byteCount); }