ksock.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KSOCK_H
00021 #define KSOCK_H
00022
00023 #include "kdemacros.h"
00024 #include <qobject.h>
00025 #include <sys/types.h>
00026
00027 #ifndef __STRICT_ANSI__
00028 #define __STRICT_ANSI__
00029 #define _WE_DEFINED_IT_
00030 #endif
00031 #include <sys/socket.h>
00032 #ifdef _WE_DEFINED_IT_
00033 #undef __STRICT_ANSI__
00034 #undef _WE_DEFINED_IT_
00035 #endif
00036
00037 #include <sys/un.h>
00038
00039 #include <netinet/in.h>
00040 class QSocketNotifier;
00041
00042 #ifdef KSOCK_NO_BROKEN
00043
00044
00045
00046
00047
00048
00049
00050 typedef sockaddr_in ksockaddr_in;
00051 #define get_sin_addr(x) x.sin_addr
00052 #define get_sin_port(x) x.sin_port
00053 #define get_sin_family(x) x.sin_family
00054 #define get_sin_paddr(x) x->sin_addr
00055 #define get_sin_pport(x) x->sin_port
00056 #define get_sin_pfamily(x) x->sin_family
00057 #endif
00058
00059 #define KSOCK_DEFAULT_DOMAIN PF_INET
00060
00061 class KSocketPrivate;
00062 class KServerSocketPrivate;
00063
00085 class KDE_DEPRECATED KSocket : public QObject
00086 {
00087 Q_OBJECT
00088 public:
00093 KSocket( int _sock );
00100 KSocket( const char *_host, unsigned short int _port, int timeOut = 30);
00101
00106 KSocket( const char * _path );
00107
00111 virtual ~KSocket();
00112
00117 int socket() const { return sock; }
00118
00127 void enableRead( bool enable );
00128
00140 void enableWrite( bool enable );
00141
00142 #ifdef KSOCK_NO_BROKEN
00143
00151 unsigned long ipv4_addr() KDE_DEPRECATED;
00152
00153
00159 static bool initSockaddr(ksockaddr_in *server_name, const char *hostname, unsigned short int port, int domain = PF_INET) KDE_DEPRECATED;
00160 #endif
00161
00162 signals:
00170 void readEvent( KSocket *s );
00171
00183 void writeEvent( KSocket *s );
00184
00189 void closeEvent( KSocket *s );
00190
00191 public slots:
00199 void slotWrite( int x);
00200
00208 void slotRead( int x );
00209
00210 protected:
00211 bool connect( const QString& _host, unsigned short int _port, int timeout = 0 );
00212 bool connect( const char *_path );
00213
00214
00215
00216
00217
00218 int sock;
00219
00220 private:
00221 KSocket(const KSocket&);
00222 KSocket& operator=(const KSocket&);
00223
00224 KSocketPrivate *d;
00225
00226 };
00227
00228
00247 class KServerSocket : public QObject
00248 {
00249 Q_OBJECT
00250 public:
00258 KServerSocket( unsigned short int _port, bool _bind = true );
00259
00267 KServerSocket( const char *_path, bool _bind = true);
00268
00272 virtual ~KServerSocket();
00273
00280 bool bindAndListen();
00281
00287 int socket() const { return sock; }
00288
00293 unsigned short int port();
00294
00295 #ifdef KSOCK_NO_BROKEN
00296
00303 unsigned long ipv4_addr();
00304 #endif
00305
00306 public slots:
00310 virtual void slotAccept( int );
00311
00312 signals:
00322 void accepted( KSocket*s );
00323
00324 protected:
00325 bool init( unsigned short int );
00326 bool init( const char *_path );
00327
00332 int sock;
00333
00334 private:
00335 KServerSocket(const KServerSocket&);
00336 KServerSocket& operator=(const KServerSocket&);
00337
00338 KServerSocketPrivate *d;
00339 };
00340
00341
00342 #endif
This file is part of the documentation for kdecore Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Apr 21 18:42:58 2004 by
doxygen 1.3.6-20040222 written by
Dimitri van Heesch, © 1997-2003