KDECore
ksocks.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _KSOCKS_H_
00019 #define _KSOCKS_H_
00020
00021 #include <qstringlist.h>
00022 #include <sys/types.h>
00023 #include <sys/time.h>
00024 #include <kstaticdeleter.h>
00025 #include <kdelibs_export.h>
00026
00027 #ifdef Q_OS_UNIX
00028
00029 class KSocksTable;
00030 class KSocksPrivate;
00031 class KLibrary;
00032 class KConfigBase;
00033 struct sockaddr;
00034
00035 typedef unsigned ksocklen_t;
00036
00037
00048 class KDECORE_EXPORT KSocks {
00049 friend class KStaticDeleter<KSocks>;
00050
00051 public:
00052
00058 static KSocks *self();
00059
00064 static bool activated();
00065
00069 void disableSocks();
00070
00074 void enableSocks();
00075
00080 bool usingSocks();
00081
00086 bool hasSocks();
00087
00092 bool hasWorkingAsyncConnect();
00093
00094
00095
00096
00101 int connect (int sockfd, const sockaddr *serv_addr,
00102 ksocklen_t addrlen);
00107 signed long int read (int fd, void *buf, unsigned long int count);
00112 signed long int write (int fd, const void *buf, unsigned long int count);
00117 int recvfrom (int s, void *buf, unsigned long int len, int flags,
00118 sockaddr *from, ksocklen_t *fromlen);
00123 int sendto (int s, const void *msg, unsigned long int len, int flags,
00124 const sockaddr *to, ksocklen_t tolen);
00129 int recv (int s, void *buf, unsigned long int len, int flags);
00134 int send (int s, const void *msg, unsigned long int len, int flags);
00139 int getsockname (int s, sockaddr *name, ksocklen_t *namelen);
00144 int getpeername (int s, sockaddr *name, ksocklen_t *namelen);
00149 int accept (int s, sockaddr *addr, ksocklen_t *addrlen);
00154 int select (int n, fd_set *readfds, fd_set *writefds,
00155 fd_set *exceptfds, struct timeval *timeout);
00160 int listen (int s, int backlog);
00161
00166 int bind (int sockfd, sockaddr *my_addr,
00167 ksocklen_t addrlen);
00168 int bind (int sockfd, const sockaddr *my_addr,
00169 ksocklen_t addrlen);
00170
00176 void die();
00177
00182 static void disable();
00183
00188 static void setConfig(KConfigBase *config);
00189
00190 private:
00191 KSocks(KConfigBase *config);
00192 ~KSocks();
00193
00194 void stopSocks();
00195
00196 static KSocks *_me;
00197 static bool _disabled;
00198 QStringList _libNames;
00199 QStringList _libPaths;
00200 bool _useSocks, _hasSocks;
00201 KLibrary* _socksLib;
00202
00203
00204 KSocksTable *_st;
00205 KSocksPrivate *d;
00206 };
00207
00208 #endif //Q_OS_UNIX
00209
00210 #endif //_KSOCKS_H_