kdecore Library API Documentation

ksocks.h

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2001 George Staikos <staikos@kde.org>
00003  
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007  
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012  
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
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 
00026 class KSocksTable;
00027 class KSocksPrivate;
00028 class KLibrary;
00029 class KConfigBase;
00030 struct sockaddr;
00031 
00032 typedef unsigned ksocklen_t;
00033 
00034 
00045 class KSocks {
00046    friend class KStaticDeleter<KSocks>;
00047 
00048 public:
00049 
00055    static KSocks *self();
00056 
00061    static bool activated();
00062 
00066    void disableSocks();
00067 
00071    void enableSocks();
00072 
00077    bool usingSocks();
00078 
00083    bool hasSocks();
00084 
00089    bool hasWorkingAsyncConnect();
00090 
00091    /*
00092     **     REIMPLEMENTATIONS OF LIBC SOCKET FUNCTIONS
00093     **/
00098     int     connect     (int sockfd, const sockaddr *serv_addr, 
00099                                 ksocklen_t addrlen);
00104     signed long int read  (int fd, void *buf, unsigned long int count);
00109     signed long int write (int fd, const void *buf, unsigned long int count);
00114     int     recvfrom    (int s, void *buf, unsigned long int len, int flags, 
00115                                 sockaddr *from, ksocklen_t *fromlen);
00120     int     sendto      (int s, const void *msg, unsigned long int len, int flags,
00121                              const sockaddr *to, ksocklen_t tolen);
00126     int     recv        (int s, void *buf, unsigned long int len, int flags);
00131     int     send        (int s, const void *msg, unsigned long int len, int flags);
00136     int     getsockname (int s, sockaddr *name, ksocklen_t *namelen);
00141     int     getpeername (int s, sockaddr *name, ksocklen_t *namelen);
00146     int     accept      (int s, sockaddr *addr, ksocklen_t *addrlen);
00151     int     select      (int n, fd_set *readfds, fd_set *writefds, 
00152                                 fd_set *exceptfds, struct timeval *timeout);
00157     int     listen      (int s, int backlog);
00158 
00163     int     bind        (int sockfd, sockaddr *my_addr, 
00164                                      ksocklen_t addrlen);
00165     int     bind        (int sockfd, const sockaddr *my_addr, 
00166                                      ksocklen_t addrlen);
00167 
00173    void die();
00174 
00179    static void disable();
00180 
00185    static void setConfig(KConfigBase *config);
00186 
00187 private:
00188    KSocks(KConfigBase *config);
00189    ~KSocks();
00190 
00191    void stopSocks();
00192 
00193    static KSocks *_me;
00194    static bool _disabled;
00195    QStringList _libNames;
00196    QStringList _libPaths;
00197    bool _useSocks, _hasSocks;
00198    KLibrary* _socksLib;
00199 
00200 
00201    KSocksTable *_st;
00202    KSocksPrivate *d;
00203 };
00204 
00205 
00206 
00207 
00208 #endif
KDE Logo
This file is part of the documentation for kdecore Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Feb 18 15:10:01 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003