From c90c389a8a8d9d8661e9772ec4144c5cf2039f23 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- libksirtet/lib/socket.h | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 libksirtet/lib/socket.h (limited to 'libksirtet/lib/socket.h') diff --git a/libksirtet/lib/socket.h b/libksirtet/lib/socket.h new file mode 100644 index 00000000..a2f47a63 --- /dev/null +++ b/libksirtet/lib/socket.h @@ -0,0 +1,65 @@ +#ifndef SOCKET_H +#define SOCKET_H + +#include + +#include + +#include "types.h" + + +class Socket +{ + public: + Socket(KExtendedSocket *, bool createNotifier = FALSE, + QObject *parent = 0, const char *name = 0); + + /** close the socket */ + ~Socket(); + + int fd() const { return _socket->fd(); } + + /** + * Accept a new socket. + */ + int accept(KExtendedSocket *&); + + /** + * @return the socket notifier associated with the socket + * (0 if none). + */ + QSocketNotifier *notifier() const { return _notifier; } + + /** + * Write data contained in the writing stream to the socket. + * It clears the stream. + * @return TRUE if all was written without error. + */ + bool write(); + bool write(const QByteArray &a); + + /** @return the QDataStream for writing. */ + WritingStream &writingStream() { return writing; } + + /** @return the size of pending data. */ + int pendingData() const; + + /** + * Read data from socket and append them to reading stream for the specified socket. + * The portion of the stream that has been read is cleared. + * @return the read size or -1 on error + */ + int read(); + + /** @return the reading stream. */ + ReadingStream &readingStream() { return reading; } + + private: + KExtendedSocket *_socket; + QSocketNotifier *_notifier; + + WritingStream writing; + ReadingStream reading; +}; + +#endif // SOCKET_H -- cgit v1.2.1