X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FClientSocketHandle.ct;h=33ef74be651e00d8f8c307c2d35696bc242e69d7;hb=d0006132bfcb3ab442cf66b600ed3fad36f1ac2c;hp=acd736b59d5fc0974df7f715e4eaa499b46bb3d1;hpb=ac6a813d9d99f7add4e13aff7a4bcd314d5604a6;p=senf.git diff --git a/Socket/ClientSocketHandle.ct b/Socket/ClientSocketHandle.ct index acd736b..33ef74b 100644 --- a/Socket/ClientSocketHandle.ct +++ b/Socket/ClientSocketHandle.ct @@ -20,7 +20,9 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline template functions +/** \file + \brief ClientSocketHandle non-inline template implementation + */ //#include "ClientSocketHandle.ih" @@ -43,7 +45,7 @@ prefix_ void senf::ClientSocketHandle::read(std::string & buffer, unsign unsigned nread = available(); if (limit>0 && nread>limit) nread = limit; - // FIXME: This is not necessary correct and more or less a hack ... + /** \fixme This is not necessary correct and more or less a hack ... */ buffer.assign(nread,0); unsigned rv = this->read(const_cast(buffer.data()),nread); if (rv < nread) @@ -65,7 +67,7 @@ prefix_ void senf::ClientSocketHandle:: readfrom(std::string & buffer, typename Policy::AddressingPolicy::Address & from) { unsigned nread = available(); - // FIXME: This is not necessary correct and more or less a hack ... + /** \fixme This is not necessary correct and more or less a hack ... */ buffer.assign(nread,0); unsigned rv = this->readfrom(const_cast(buffer.data()), nread, from); if (rv < nread) @@ -98,8 +100,14 @@ prefix_ unsigned senf::ClientSocketHandle::available() { unsigned nread = this->protocol().available(); if (nread == 0 && this->blocking()) { - this->waitReadable(); - nread = this->protocol().available(); + // We have to block explicitly here so we can return the + // number of bytes available explicitly. If no more date can + // be expected to arive (i.e. the other end has closed the + // connection), the socket will always be in the readable + // state. This is the only case when available() will return + // 0. + this->waitReadable(); + nread = this->protocol().available(); } return nread; }