summaryrefslogtreecommitdiffstats
path: root/libksirtet/lib/socket.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitc90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch)
tree6d8391395bce9eaea4ad78958617edb20c6a7573 /libksirtet/lib/socket.h
downloadtdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz
tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip
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
Diffstat (limited to 'libksirtet/lib/socket.h')
-rw-r--r--libksirtet/lib/socket.h65
1 files changed, 65 insertions, 0 deletions
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 <qsocketnotifier.h>
+
+#include <kextsock.h>
+
+#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