[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: Extending KExtendedSocket class
From: Thiago Macieira <thiagom () wanadoo ! fr>
Date: 2001-12-17 12:23:24
[Download RAW message or body]
Rob Kaper wrote:
> Can the KExtendedSocket class be extended to have some of the handy features
> present in QSocket? I'm thinking of handy stuff like
>
> bool canReadLine () const
> virtual QString readLine ()
> void readyRead ()
>
Well, the class can of course be extended, even inherited if needed
(KExt2Socket?). But, in this case, I must point out that those things
already exist.
KExtendedSocket doesn't define them itself, but they are available from
inherited classes:
bool KBufferedIO::canReadLine() const
Q_LONG QIODevice::readLine(char *, Q_ULONG)
int KBufferedIO::bytesAvailable() const
readLine() can be used always, but, as Qt documentation says, it could
be implemented in a better way. Probably at KBufferedIO.
as for the other two, you must remember to place the socket in buffered
mode, by passing the KExtendedSocket::bufferedSocket flag to the
constructor or by using setBufferSize. If the socket isn't at least
input-buffered, the class won't read from the socket for you, so it
can't tell whether there is data or not.
KExtendedSocket already does full buffering for you. I tried to imitate
the behaviour from QSocket as best as I could, including unlimited
buffering. In my test cases, there hasn't been any problem, but I don't
think buffered KExtendedSockets were ever put to real use, so a few
problems could still arise.
Also note that you shouldn't use QSocket anymore. It doesn't take into
account the global proxies.
--
Thiago Macieira - UFOT Registry number: 1001
thiagom@mail.com
ICQ UIN: 1967141 PGP: 0x8F2978D5 and 0xEA9037A5 (PGP 2.x)
Registered Linux user #65028
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic