• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • network
syssocket.h
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * Copyright (C) 2003,2005 Thiago Macieira <thiago@kde.org>
3  *
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef KDE_SYSSOCKET_H
26 #define KDE_SYSSOCKET_H
27 
28 #ifdef KSOCKETBASE_H
29 #error syssocket.h must be included before ksocketbase.h!
30 #endif
31 
32 // needed for Solaris, but shouldn't hurt on other operating systems
33 // and to avoid ifdef mess, rather include them for all
34 #include <unistd.h>
35 #ifdef HAVE_STROPTS_H
36 #include <stropts.h>
37 #endif
38 
39 #include <sys/types.h>
40 #include <sys/socket.h>
41 #include <sys/ioctl.h>
42 
43 namespace {
44 
45  /*
46  * These function here are just wrappers for the real system calls.
47  *
48  * Unfortunately, a number of systems out there work by redefining
49  * symbols through the preprocessor -- symbols that we need.
50  *
51  * So we write wrappers for all the low-level system calls.
52  *
53  * Qt has a very similar implementation. I got the idea from them, but
54  * I copied no code.
55  */
56 
57  // socket
58  inline int kde_socket(int af, int style, int protocol)
59  {
60  return ::socket(af, style, protocol);
61  }
62 
63  // bind
64  inline int kde_bind(int fd, const struct sockaddr* sa, socklen_t len)
65  {
66  return ::bind(fd, sa, len);
67  }
68 
69  // listen
70  inline int kde_listen(int fd, int backlog)
71  {
72  return ::listen(fd, backlog);
73  }
74 
75  // connect
76  inline int kde_connect(int fd, const struct sockaddr* sa, socklen_t len)
77  {
78  return ::connect(fd, (struct sockaddr*)sa, len);
79  }
80 
81  // accept
82  inline int kde_accept(int fd, struct sockaddr* sa, socklen_t* len)
83  {
84  return ::accept(fd, sa, len);
85  }
86 
87  // getpeername
88  inline int kde_getpeername(int fd, struct sockaddr* sa, socklen_t* len)
89  {
90  return ::getpeername(fd, sa, len);
91  }
92 
93  // getsockname
94  inline int kde_getsockname(int fd, struct sockaddr* sa, socklen_t* len)
95  {
96  return ::getsockname(fd, sa, len);
97  }
98 
99  // ioctl
100  inline int kde_ioctl(int fd, int cmd, int* argp)
101  {
102 #if defined _WIN32 || defined _WIN64
103  unsigned long l_argp = *argp;
104  int iRet = ::ioctlsocket(fd, cmd, &l_argp);
105  *argp = (int) l_argp;
106  return iRet;
107 #else
108  return ::ioctl(fd, cmd, argp);
109 #endif
110  }
111 
112 } // anonymous namespace
113 
114 #endif
KSocketFactory::listen
QTcpServer * listen(const QString &protocol, const QHostAddress &address=QHostAddress::Any, quint16 port=0, QObject *parent=0)
Opens a TCP/IP socket for listening protocol protocol, binding only at address address.
Definition: ksocketfactory.cpp:115
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:12 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal