KDECore
syssocket.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
00019
00020
00021
00022
00023
00024
00025 #ifndef KDE_SYSSOCKET_H
00026 #define KDE_SYSSOCKET_H
00027
00028 #ifdef KSOCKETBASE_H
00029 #error syssocket.h must be included before ksocketbase.h!
00030 #endif
00031
00032
00033
00034 #include <unistd.h>
00035 #ifdef HAVE_STROPTS_H
00036 #include <stropts.h>
00037 #endif
00038
00039 #include <sys/types.h>
00040 #include <sys/socket.h>
00041 #include <sys/ioctl.h>
00042
00043 namespace {
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 inline int kde_socket(int af, int style, int protocol)
00059 {
00060 return ::socket(af, style, protocol);
00061 }
00062
00063
00064 inline int kde_bind(int fd, const struct sockaddr* sa, socklen_t len)
00065 {
00066 return ::bind(fd, sa, len);
00067 }
00068
00069
00070 inline int kde_listen(int fd, int backlog)
00071 {
00072 return ::listen(fd, backlog);
00073 }
00074
00075
00076 inline int kde_connect(int fd, const struct sockaddr* sa, socklen_t len)
00077 {
00078 return ::connect(fd, (struct sockaddr*)sa, len);
00079 }
00080
00081
00082 inline int kde_accept(int fd, struct sockaddr* sa, socklen_t* len)
00083 {
00084 return ::accept(fd, sa, len);
00085 }
00086
00087
00088 inline int kde_getpeername(int fd, struct sockaddr* sa, socklen_t* len)
00089 {
00090 return ::getpeername(fd, sa, len);
00091 }
00092
00093
00094 inline int kde_getsockname(int fd, struct sockaddr* sa, socklen_t* len)
00095 {
00096 return ::getsockname(fd, sa, len);
00097 }
00098
00099
00100 inline int kde_ioctl(int fd, int cmd, int* argp)
00101 {
00102 #if defined _WIN32 || defined _WIN64
00103 unsigned long l_argp = *argp;
00104 int iRet = ::ioctlsocket(fd, cmd, &l_argp);
00105 *argp = (int) l_argp;
00106 return iRet;
00107 #else
00108 return ::ioctl(fd, cmd, argp);
00109 #endif
00110 }
00111
00112 }
00113
00114 #endif