Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qnativesocketengine_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QNATIVESOCKETENGINE_P_P_H
6#define QNATIVESOCKETENGINE_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "private/qabstractsocketengine_p.h"
20#include "private/qnativesocketengine_p.h"
21
22#ifndef Q_OS_WIN
23# include <netinet/in.h>
24#else
25# include <winsock2.h>
26# include <ws2tcpip.h>
27# include <mswsock.h>
28#endif
29
31
32#ifdef Q_OS_WIN
33
34// The following definitions are copied from the MinGW header mswsock.h which
35// was placed in the public domain. The WSASendMsg and WSARecvMsg functions
36// were introduced with Windows Vista, so some Win32 headers are lacking them.
37// There are no known versions of Windows CE or Embedded that contain them.
38# ifndef WSAID_WSARECVMSG
39typedef INT (WINAPI *LPFN_WSARECVMSG)(SOCKET s, LPWSAMSG lpMsg,
40 LPDWORD lpdwNumberOfBytesRecvd,
41 LPWSAOVERLAPPED lpOverlapped,
42 LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
43# define WSAID_WSARECVMSG {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}
44# endif // !WSAID_WSARECVMSG
45# ifndef WSAID_WSASENDMSG
46typedef struct {
47 LPWSAMSG lpMsg;
48 DWORD dwFlags;
49 LPDWORD lpNumberOfBytesSent;
50 LPWSAOVERLAPPED lpOverlapped;
51 LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine;
52} WSASENDMSG, *LPWSASENDMSG;
53
54typedef INT (WSAAPI *LPFN_WSASENDMSG)(SOCKET s, LPWSAMSG lpMsg, DWORD dwFlags,
55 LPDWORD lpNumberOfBytesSent,
56 LPWSAOVERLAPPED lpOverlapped,
57 LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
58
59# define WSAID_WSASENDMSG {0xa441e712,0x754f,0x43ca,{0x84,0xa7,0x0d,0xee,0x44,0xcf,0x60,0x6d}}
60# endif // !WSAID_WSASENDMSG
61#endif // Q_OS_WIN
62
64 sockaddr a;
65 sockaddr_in a4;
66 sockaddr_in6 a6;
67};
68
69class QSocketNotifier;
70
72{
73 Q_DECLARE_PUBLIC(QNativeSocketEngine)
74public:
77
79
81
82#if defined(Q_OS_WIN)
83 LPFN_WSASENDMSG sendmsg;
84 LPFN_WSARECVMSG recvmsg;
85# endif
118
121
122 // native functions
125
127
130 bool nativeListen(int backlog);
132#ifndef QT_NO_NETWORKINTERFACE
133 bool nativeJoinMulticastGroup(const QHostAddress &groupAddress,
134 const QNetworkInterface &iface);
135 bool nativeLeaveMulticastGroup(const QHostAddress &groupAddress,
136 const QNetworkInterface &iface);
139#endif
141
142 bool nativeHasPendingDatagrams() const;
145 QAbstractSocketEngine::PacketHeaderOptions options);
148 qint64 nativeWrite(const char *data, qint64 length);
149 int nativeSelect(QDeadlineTimer deadline, bool selectForRead) const;
150 int nativeSelect(QDeadlineTimer deadline, bool checkRead, bool checkWrite,
151 bool *selectForRead, bool *selectForWrite) const;
152
153 void nativeClose();
154
155 bool checkProxy(const QHostAddress &address);
157
162 void setPortAndAddress(quint16 port, const QHostAddress &address, qt_sockaddr *aa, QT_SOCKLEN_T *sockAddrSize)
163 {
164 switch (socketProtocol) {
167 // force to IPv6
168 setSockaddr(&aa->a6, address, port);
169 *sockAddrSize = sizeof(sockaddr_in6);
170 return;
171
173 // force to IPv4
174 setSockaddr(&aa->a4, address, port);
175 *sockAddrSize = sizeof(sockaddr_in);
176 return;
177
179 // don't force
180 break;
181 }
182 *sockAddrSize = setSockaddr(&aa->a, address, port);
183 }
184
185};
186
188
189#endif // QNATIVESOCKETENGINE_P_P_H
QAbstractSocket::NetworkLayerProtocol socketProtocol
SocketError
This enum describes the socket errors that can occur.
SocketType
This enum describes the transport layer protocol.
\inmodule QtCore
The QHostAddress class provides an IP address.
@ UnknownNetworkLayerProtocol
bool createNewSocket(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol &protocol)
QNetworkInterface nativeMulticastInterface() const
qint64 nativeWrite(const char *data, qint64 length)
bool nativeJoinMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface)
bool setOption(QNativeSocketEngine::SocketOption option, int value)
int nativeSelect(QDeadlineTimer deadline, bool selectForRead) const
void setError(QAbstractSocket::SocketError error, ErrorString errorString) const
bool nativeSetMulticastInterface(const QNetworkInterface &iface)
bool checkProxy(const QHostAddress &address)
bool fetchConnectionParameters()
Fetches information about both ends of the connection: whatever is available.
bool nativeBind(const QHostAddress &address, quint16 port)
qint64 nativeSendDatagram(const char *data, qint64 length, const QIpPacketHeader &header)
bool nativeConnect(const QHostAddress &address, quint16 port)
void setPortAndAddress(quint16 port, const QHostAddress &address, qt_sockaddr *aa, QT_SOCKLEN_T *sockAddrSize)
bool nativeLeaveMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface)
QHostAddress adjustAddressProtocol(const QHostAddress &address) const
qint64 nativeRead(char *data, qint64 maxLength)
qint64 nativeReceiveDatagram(char *data, qint64 maxLength, QIpPacketHeader *header, QAbstractSocketEngine::PacketHeaderOptions options)
The QNativeSocketEngine class provides low level access to a socket.
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.
\inmodule QtCore
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputPortEXT port
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLdouble s
[6]
Definition qopenglext.h:235
GLsizei maxLength
GLuint GLuint64EXT address
GLuint GLenum option
const char SOCKET[]
Definition uistrings.cpp:29
unsigned short quint16
Definition qtypes.h:48
long long qint64
Definition qtypes.h:60
ptrdiff_t qintptr
Definition qtypes.h:166
QDeadlineTimer deadline(30s)