• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

  • kdecore
ksock.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 1997 Torben Weis (weis@kde.org)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 #ifndef KSOCK_H
21 #define KSOCK_H
22 
23 #include "kdelibs_export.h"
24 
25 #ifdef Q_MOC_RUN
26 #define Q_OS_UNIX
27 #endif // Q_MOC_RUN
28 
29 #ifdef Q_OS_UNIX
30 
31 #include <tqobject.h>
32 #include <sys/types.h>
33 // we define STRICT_ANSI to get rid of some warnings in glibc
34 #ifndef __STRICT_ANSI__
35 #define __STRICT_ANSI__
36 #define _WE_DEFINED_IT_
37 #endif
38 #include <sys/socket.h>
39 #ifdef _WE_DEFINED_IT_
40 #undef __STRICT_ANSI__
41 #undef _WE_DEFINED_IT_
42 #endif
43 
44 #include <sys/un.h>
45 
46 #include <netinet/in.h>
47 class TQSocketNotifier;
48 
49 #ifdef KSOCK_NO_BROKEN
50 // This is here for compatibility with old applications still using the constants
51 // Never use them in new programs
52 
53 // Here are a whole bunch of hackish macros that allow one to
54 // get at the correct member of ksockaddr_in
55 // But since ksockaddr_in is IPv4-only, and deprecated...
56 
57 typedef sockaddr_in ksockaddr_in;
58 #define get_sin_addr(x) x.sin_addr
59 #define get_sin_port(x) x.sin_port
60 #define get_sin_family(x) x.sin_family
61 #define get_sin_paddr(x) x->sin_addr
62 #define get_sin_pport(x) x->sin_port
63 #define get_sin_pfamily(x) x->sin_family
64 #endif
65 
66 #define KSOCK_DEFAULT_DOMAIN PF_INET
67 
68 class KSocketPrivate;
69 class KServerSocketPrivate;
70 
91 class KDECORE_EXPORT KSocket : public TQObject
92 {
93  Q_OBJECT
94 public:
99  KSocket( int _sock ) KDE_DEPRECATED;
106  KSocket( const char *_host, unsigned short int _port, int timeOut = 30) KDE_DEPRECATED;
107 
112  KSocket( const char * _path ) KDE_DEPRECATED;
113 
117  virtual ~KSocket();
118 
123  int socket() const { return sock; }
124 
133  void enableRead( bool enable );
134 
146  void enableWrite( bool enable );
147 
148 #ifdef KSOCK_NO_BROKEN
149  // BCI: remove in libkdecore.so.4
157  unsigned long ipv4_addr() KDE_DEPRECATED;
158 
159  // BCI: remove in libkdecore.so.4
165  static bool initSockaddr(ksockaddr_in *server_name, const char *hostname, unsigned short int port, int domain = PF_INET) KDE_DEPRECATED;
166 #endif
167 
168 signals:
176  void readEvent( KSocket *s );
177 
189  void writeEvent( KSocket *s );
190 
195  void closeEvent( KSocket *s );
196 
197 public slots:
205  void slotWrite( int x);
206 
214  void slotRead( int x );
215 
216 protected:
217  bool connect( const TQString& _host, unsigned short int _port, int timeout = 0 );
218  bool connect( const char *_path );
219 
220  /******************************************************
221  * The file descriptor for this socket. sock may be -1.
222  * This indicates that it is not connected.
223  */
224  int sock;
225 
226 private:
227  KSocket(const KSocket&);
228  KSocket& operator=(const KSocket&);
229 
230  KSocketPrivate *d;
231 
232 };
233 
234 
254 class KDECORE_EXPORT KServerSocket : public TQObject
255 {
256  Q_OBJECT
257 public:
265  KServerSocket( unsigned short int _port, bool _bind = true );
266 
274  KServerSocket( const char *_path, bool _bind = true);
275 
279  virtual ~KServerSocket();
280 
287  bool bindAndListen();
288 
294  int socket() const { return sock; }
295 
300  unsigned short int port();
301 
302 #ifdef KSOCK_NO_BROKEN
303  // BCI: remove in libkdecore.so.4
310  unsigned long ipv4_addr();
311 #endif
312 
313 public slots:
317  virtual void slotAccept( int ); // why is this virtual?
318 
319 signals:
329  void accepted( KSocket*s );
330 
331 protected:
332  bool init( unsigned short int );
333  bool init( const char *_path );
334 
339  int sock;
340 
341 private:
342  KServerSocket(const KServerSocket&);
343  KServerSocket& operator=(const KServerSocket&);
344 
345  KServerSocketPrivate *d;
346 };
347 
348 #endif //Q_OS_UNIX
349 
350 #endif

kdecore

Skip menu "kdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |