Brief description of class still missing. More...
#include <TcpClientStream.h>
Public Member Functions | |
DynamicBuffer * | buffer () const |
virtual bool | connect (uint16_t port) |
virtual void | event (short type) |
virtual short | eventTypes () |
virtual void | hungUp () |
const Address & | peer () const |
TcpClientStream (int fileDescriptor, const Address &peer) | |
TcpClientStream (const Address &peer) | |
bool | write (const char *bytes, int byteCount) const |
bool | writeNoGateway (const char *bytes, int byteCount) const |
bool | writePartial (const char *bytes, int byteCount) const |
bool | writePartialNoGateway (const char *bytes, int byteCount) const |
virtual | ~TcpClientStream () |
Protected Member Functions | |
void | setBuffer (DynamicBuffer *buffer) |
Brief description of class still missing.
Full description of class still missing
GpCoreTools::TcpClientStream::TcpClientStream | ( | int | fileDescriptor, |
const Address & | peer | ||
) |
Description of constructor still missing
References peer(), GpCoreTools::Stream::setFileDescriptor(), and TRACE.
: Stream() { TRACE; setFileDescriptor(fileDescriptor); _peer=peer; _buffer=0; }
GpCoreTools::TcpClientStream::TcpClientStream | ( | const Address & | peer | ) |
Description of constructor still missing
References GpCoreTools::Stream::fileDescriptor(), peer(), GpCoreTools::Stream::setFileDescriptor(), TRACE, and write().
{ TRACE; setFileDescriptor(socket(AF_INET, SOCK_STREAM, 0)); if(fileDescriptor()<=0) { Log::write(0, "%s\n", strerror(errno)); } _peer=peer; _buffer=0; }
GpCoreTools::TcpClientStream::~TcpClientStream | ( | ) | [virtual] |
DynamicBuffer* GpCoreTools::TcpClientStream::buffer | ( | ) | const [inline] |
Reimplemented in GpsStream, CubeTcpStream, TimeSlaveStream, NetClient, LinkStream, CrystalfontzStream, SystemClient, and MasterStream.
{return _buffer;}
bool GpCoreTools::TcpClientStream::connect | ( | uint16_t | port | ) | [virtual] |
Reimplemented in LinkStream.
References GpCoreTools::Stream::fileDescriptor(), GpCoreTools::Address::toString(), TRACE, GpCoreTools::Address::value(), and write().
Referenced by GpCoreTools::ScreenClient::connect(), and TimeRequest::exec().
{ TRACE; sockaddr_in addr; addr.sin_family=AF_INET; addr.sin_port=htons(port); addr.sin_addr.s_addr=_peer.value(); Log::write(1, "connecting to %s:%hu (socket %i)\n", _peer.toString().data(), port, fileDescriptor()); if(::connect(fileDescriptor(), (sockaddr *)&addr, sizeof(sockaddr_in))<0) { Log::write(1, "%s\n", strerror(errno)); return false; } else { Log::write(1, "connected to %s:%hu (socket %i)\n", inet_ntoa(addr.sin_addr), port, fileDescriptor()); return true; } }
void GpCoreTools::TcpClientStream::event | ( | short | type | ) | [virtual] |
Implements GpCoreTools::Stream.
References GpCoreTools::Stream::close(), GpCoreTools::Stream::fileDescriptor(), hungUp(), GpCoreTools::DynamicBuffer::read(), GpCoreTools::Address::toString(), TRACE, and write().
{ TRACE; if(type & POLLIN) { if(_buffer) { if(!_buffer->read()) { Log::write(1, "error reading data from %s (socket %i)\n", _peer.toString().data(), fileDescriptor()); } } } if(type & POLLRDHUP) { Log::write(1, "connection hung up with %s (socket %i)\n", _peer.toString().data(), fileDescriptor()); close(); hungUp(); } }
virtual short GpCoreTools::TcpClientStream::eventTypes | ( | ) | [inline, virtual] |
Implements GpCoreTools::Stream.
{return POLLIN | POLLRDHUP;}
virtual void GpCoreTools::TcpClientStream::hungUp | ( | ) | [inline, virtual] |
Reimplemented in MasterStream, LinkStream, GpCoreTools::ScreenClient, and TimeSlaveStream.
Referenced by event().
{}
const Address& GpCoreTools::TcpClientStream::peer | ( | ) | const [inline] |
Referenced by LinkStream::connect(), LinkStream::hungUp(), and TcpClientStream().
{return _peer;}
void GpCoreTools::TcpClientStream::setBuffer | ( | DynamicBuffer * | buffer | ) | [inline, protected] |
Referenced by MasterStream::connect(), LinkStream::connect(), CrystalfontzStream::CrystalfontzStream(), CubeTcpStream::CubeTcpStream(), GpsStream::GpsStream(), LinkStream::LinkStream(), MasterStream::MasterStream(), NetClient::NetClient(), SystemClient::SystemClient(), TimeMasterStream::TimeMasterStream(), and TimeSlaveStream::TimeSlaveStream().
{_buffer=buffer;}
bool GpCoreTools::TcpClientStream::write | ( | const char * | bytes, |
int | byteCount | ||
) | const [inline] |
Referenced by connect(), event(), TimeRequest::exec(), and TcpClientStream().
{ return ::write(fileDescriptor(), bytes, byteCount)==byteCount; }
bool GpCoreTools::TcpClientStream::writeNoGateway | ( | const char * | bytes, |
int | byteCount | ||
) | const [inline] |
Referenced by PeerTracker::addFromMasterRoute(), and PeerTracker::removeFromMasterRoute().
{ return ::send(fileDescriptor(), bytes, byteCount, MSG_DONTROUTE)==byteCount; }
bool GpCoreTools::TcpClientStream::writePartial | ( | const char * | bytes, |
int | byteCount | ||
) | const [inline] |
Referenced by GpCoreTools::ScreenClient::write().
{ return ::send(fileDescriptor(), bytes, byteCount, MSG_MORE)==byteCount; }
bool GpCoreTools::TcpClientStream::writePartialNoGateway | ( | const char * | bytes, |
int | byteCount | ||
) | const [inline] |
Referenced by PeerTracker::addFromMasterRoute(), and PeerTracker::removeFromMasterRoute().
{ return ::send(fileDescriptor(), bytes, byteCount, MSG_DONTROUTE | MSG_MORE)==byteCount; }