Qyoto
4.0.7
Qyoto is a C# language binding for Qt
|
The QUdpSocket class provides a UDP socket. More...
Public Member Functions | |
QUdpSocket (QObject parent=null) | |
More... | |
override void | CreateProxy () |
new bool | Bind (QHostAddress address, ushort port) |
More... | |
new bool | Bind (QHostAddress address, ushort port, QUdpSocket.BindFlag mode) |
More... | |
new bool | Bind (ushort port=0) |
More... | |
new bool | Bind (ushort port, QUdpSocket.BindFlag mode) |
More... | |
new bool | JoinMulticastGroup (QHostAddress groupAddress) |
More... | |
new bool | JoinMulticastGroup (QHostAddress groupAddress, QNetworkInterface iface) |
More... | |
new bool | LeaveMulticastGroup (QHostAddress groupAddress) |
More... | |
new bool | LeaveMulticastGroup (QHostAddress groupAddress, QNetworkInterface iface) |
More... | |
new long | ReadDatagram (Pointer< sbyte > data, long maxlen, QHostAddress host=null) |
More... | |
new long | ReadDatagram (Pointer< sbyte > data, long maxlen, QHostAddress host, ref ushort port) |
More... | |
new long | WriteDatagram (QByteArray datagram, QHostAddress host, ushort port) |
More... | |
new long | WriteDatagram (string data, long len, QHostAddress host, ushort port) |
More... | |
new void | Dispose () |
![]() | |
QAbstractSocket (QAbstractSocket.SocketType socketType, QObject parent) | |
More... | |
new void | Abort () |
More... | |
override void | Close () |
More... | |
new void | ConnectToHost (QHostAddress address, ushort port, QIODevice.OpenModeFlag mode=QIODevice.OpenModeFlag.ReadWrite) |
More... | |
new void | ConnectToHost (string hostName, ushort port, QIODevice.OpenModeFlag mode=QIODevice.OpenModeFlag.ReadWrite) |
More... | |
new void | DisconnectFromHost () |
More... | |
new QAbstractSocket.SocketError | Error () |
More... | |
new bool | SetSocketDescriptor (int socketDescriptor, QAbstractSocket.SocketState state=QAbstractSocket.SocketState.ConnectedState, QIODevice.OpenModeFlag openMode=QIODevice.OpenModeFlag.ReadWrite) |
More... | |
new void | SetSocketOption (QAbstractSocket.SocketOption option, object value) |
More... | |
new object | socketOption (QAbstractSocket.SocketOption option) |
More... | |
override bool | WaitForBytesWritten (int msecs=30000) |
More... | |
new bool | WaitForConnected (int msecs=30000) |
More... | |
new bool | WaitForDisconnected (int msecs=30000) |
More... | |
override bool | WaitForReadyRead (int msecs=30000) |
More... | |
new void | Dispose () |
![]() | |
QIODevice () | |
More... | |
QIODevice (QObject parent) | |
More... | |
new bool | GetChar (Pointer< sbyte > c) |
More... | |
virtual bool | Open (QIODevice.OpenModeFlag mode) |
More... | |
new QByteArray | Peek (long maxlen) |
More... | |
new long | Peek (Pointer< sbyte > data, long maxlen) |
More... | |
new bool | PutChar (char c) |
More... | |
new QByteArray | Read (long maxlen) |
More... | |
new long | Read (Pointer< sbyte > data, long maxlen) |
More... | |
new QByteArray | ReadAll () |
More... | |
new QByteArray | ReadLine (long maxlen=0) |
More... | |
new long | ReadLine (Pointer< sbyte > data, long maxlen) |
More... | |
virtual bool | Reset () |
More... | |
virtual bool | Seek (long pos) |
More... | |
new void | SetTextModeEnabled (bool enabled) |
More... | |
new void | UngetChar (char c) |
More... | |
new long | Write (QByteArray data) |
More... | |
new long | Write (string data) |
More... | |
new long | Write (string data, long len) |
More... | |
new void | Dispose () |
![]() | |
QObject (QObject parent=null) | |
More... | |
new bool | BlockSignals (bool b) |
More... | |
new bool | Connect (QObject sender, string signal, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
More... | |
new void | DeleteLater () |
More... | |
new bool | Disconnect (QObject receiver, string member=null) |
More... | |
new bool | Disconnect (string signal=null, QObject receiver=null, string member=null) |
More... | |
new void | DumpObjectInfo () |
More... | |
new void | DumpObjectTree () |
More... | |
virtual bool | OnEvent (QEvent e) |
More... | |
virtual bool | EventFilter (QObject watched, QEvent @event) |
More... | |
new bool | Inherits (string classname) |
More... | |
new void | InstallEventFilter (QObject filterObj) |
More... | |
new void | KillTimer (int id) |
More... | |
new object | Property (string name) |
More... | |
new void | RemoveEventFilter (QObject obj) |
More... | |
new bool | SetProperty (string name, object value) |
More... | |
new void | SetUserData (uint id, QObjectUserData data) |
new int | StartTimer (int interval) |
More... | |
new QObjectUserData | UserData (uint id) |
new void | Dispose () |
![]() | |
delegate QTextStream | FuncQTextStreamQTextStream (QTextStream qTextStream) |
delegate void | ActionQtMsgTypeString (QtMsgType qtMsgType, string @string) |
delegate QObject | FuncQObject () |
delegate string | FuncStringQByteArray (QByteArray qByteArray) |
delegate QByteArray | FuncQByteArrayString (string @string) |
Static Public Member Functions | |
static string | Tr (string s, string c=null) |
static string | Tr (string s, string c, int n) |
static string | TrUtf8 (string s, string c=null) |
static string | TrUtf8 (string s, string c, int n) |
![]() | |
static string | Tr (string s, string c=null) |
static string | Tr (string s, string c, int n) |
static string | TrUtf8 (string s, string c=null) |
static string | TrUtf8 (string s, string c, int n) |
![]() | |
static string | Tr (string s, string c=null) |
static string | Tr (string s, string c, int n) |
static string | TrUtf8 (string s, string c=null) |
static string | TrUtf8 (string s, string c, int n) |
![]() | |
static bool | Connect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod method, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
More... | |
static bool | Connect (QObject sender, string signal, QObject receiver, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
More... | |
static bool | Disconnect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod member) |
More... | |
static bool | Disconnect (QObject sender, string signal, QObject receiver, string member) |
More... | |
static string | Tr (string s, string c=null) |
More... | |
static string | Tr (string s, string c, int n) |
More... | |
static string | TrUtf8 (string s, string c=null) |
More... | |
static string | TrUtf8 (string s, string c, int n) |
More... | |
![]() | |
static QDataStream | Write (QDataStream s, object p) |
static QDataStream | Write (QDataStream stream, QSizeF size) |
More... | |
static QDataStream | Write (QDataStream stream, QPoint point) |
More... | |
static QTextStream | Write (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
static QDataStream | Write (QDataStream stream, QLineF line) |
More... | |
static QDataStream | Write (QDataStream stream, QPointF point) |
More... | |
static QDataStream | Write (QDataStream @out, QChar chr) |
More... | |
static QDataStream | Write (QDataStream @out, QByteArray ba) |
More... | |
static QDataStream | Write (QDataStream stream, QEasingCurve easing) |
More... | |
static QDataStream | Write (QDataStream stream, QRectF rectangle) |
More... | |
static QDataStream | Write (QDataStream @out, QDateTime dateTime) |
More... | |
static QDataStream | Write (QDataStream @out, QUrl url) |
More... | |
static QDataStream | Write (QDataStream @out, QTime time) |
More... | |
static QDataStream | Write (QDataStream arg1, QLocale arg2) |
static QDataStream | Write (QDataStream @out, QBitArray ba) |
More... | |
static QDataStream | Write (QDataStream s, QUuid id) |
More... | |
static QDataStream | Write (QDataStream stream, QLine line) |
More... | |
static QDataStream | Write (QDataStream @out, QDate date) |
More... | |
static QDataStream | Write (QDataStream @out, QRegExp regExp) |
More... | |
static QDataStream | Write (QDataStream stream, QRect rectangle) |
More... | |
static QDataStream | Write (QDataStream stream, QSize size) |
More... | |
static QDataStream | Write (QDataStream s, QVariant.Type p) |
static QDataStream | Write (QDataStream arg1, string arg2) |
static QDataStream | Write (QDataStream @out, System.Collections.Generic.List< string > list) |
More... | |
static QDataStream | Read (QDataStream @in, QChar chr) |
More... | |
static QDataStream | Read (QDataStream arg1, QLocale arg2) |
static QDataStream | Read (QDataStream stream, QRect rectangle) |
More... | |
static QDataStream | Read (QDataStream arg1, QEasingCurve arg2) |
static QDataStream | Read (QDataStream @in, QDate date) |
More... | |
static QDataStream | Read (QDataStream @in, QUrl url) |
More... | |
static QDataStream | Read (QDataStream s, QUuid id) |
More... | |
static QTextStream | Read (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
static QDataStream | Read (QDataStream stream, QLineF line) |
More... | |
static QDataStream | Read (QDataStream stream, QRectF rectangle) |
More... | |
static QDataStream | Read (QDataStream stream, QPointF point) |
More... | |
static QDataStream | Read (QDataStream stream, QLine line) |
More... | |
static QDataStream | Read (QDataStream @in, QBitArray ba) |
More... | |
static QDataStream | Read (QDataStream stream, QSize size) |
More... | |
static QDataStream | Read (QDataStream @in, QDateTime dateTime) |
More... | |
static QDataStream | Read (QDataStream @in, QTime time) |
More... | |
static QDataStream | Read (QDataStream stream, QPoint point) |
More... | |
static QDataStream | Read (QDataStream @in, QRegExp regExp) |
More... | |
static QDataStream | Read (QDataStream s, object p) |
static QDataStream | Read (QDataStream @in, QByteArray ba) |
More... | |
static QDataStream | Read (QDataStream stream, QSizeF size) |
More... | |
static QDataStream | Read (QDataStream arg1, string arg2) |
static QDataStream | Read (QDataStream s, QVariant.Type p) |
static QDataStream | Read (QDataStream @in, System.Collections.Generic.List< string > list) |
More... | |
static double | QAcos (double v) |
More... | |
static void | QAddPostRoutine (System.Action ptr) |
More... | |
static double | QAsin (double v) |
More... | |
static double | QAtan (double v) |
More... | |
static double | QAtan2 (double x, double y) |
More... | |
static void | QBadAlloc () |
static int | QCeil (double v) |
More... | |
static ushort | QChecksum (string s, uint len) |
More... | |
static QByteArray | QCompress (QByteArray data, int compressionLevel=-1) |
More... | |
static QByteArray | QCompress (Pointer< byte > data, int nbytes, int compressionLevel=-1) |
More... | |
static double | QCos (double v) |
More... | |
static double | QExp (double v) |
More... | |
static double | QFabs (double v) |
static double | QFastCos (double x) |
static double | QFastSin (double x) |
static string | QFlagLocation (string method) |
static int | QFloor (double v) |
More... | |
static bool | QFuzzyCompare (double p1, double p2) |
More... | |
static bool | QFuzzyCompare (float p1, float p2) |
More... | |
static bool | QFuzzyIsNull (double d) |
static bool | QFuzzyIsNull (float f) |
static uint | QHash (QBitArray key) |
More... | |
static uint | QHash (QChar key) |
More... | |
static uint | QHash (QStringRef key) |
static uint | QHash (QUrl url) |
More... | |
static uint | QHash (QPersistentModelIndex index) |
static uint | QHash (QByteArray key) |
More... | |
static uint | QHash (QModelIndex index) |
static uint | QHash (uint key) |
More... | |
static uint | QHash (char key) |
More... | |
static uint | QHash (byte key) |
More... | |
static uint | QHash (short key) |
More... | |
static uint | QHash (NativeLong key) |
More... | |
static uint | QHash (ushort key) |
More... | |
static uint | QHash (long key) |
More... | |
static uint | QHash (ulong key) |
More... | |
static uint | QHash (int key) |
More... | |
static uint | QHash (string key) |
More... | |
static uint | QHash (NativeULong key) |
More... | |
static Qt.ActionQtMsgTypeString | QInstallMsgHandler (Qt.ActionQtMsgTypeString handler) |
More... | |
static int | QIntCast (float f) |
static int | QIntCast (double f) |
static bool | QIsFinite (double d) |
static bool | QIsFinite (float f) |
static bool | QIsInf (float f) |
static bool | QIsInf (double d) |
static bool | QIsNaN (float f) |
static bool | QIsNaN (double d) |
static bool | QIsNull (float f) |
static bool | QIsNull (double d) |
static double | QLn (double v) |
More... | |
static double | QPow (double x, double y) |
More... | |
static void | QRegisterStaticPluginInstanceFunction (Qt.FuncQObject function) |
More... | |
static void | QRemovePostRoutine (System.Action arg1) |
static int | QRound (double d) |
More... | |
static long | QRound64 (double d) |
More... | |
static double | QSin (double v) |
More... | |
static double | QSqrt (double v) |
More... | |
static bool | QStringComparisonHelper (QStringRef s1, string s2) |
static double | QTan (double v) |
More... | |
static QByteArray | QUncompress (QByteArray data) |
More... | |
static QByteArray | QUncompress (Pointer< byte > data, int nbytes) |
More... | |
static void | Qbswap_helper (Pointer< byte > src, Pointer< byte > dest, int size) |
static QByteArray | Qgetenv (string varName) |
More... | |
static bool | Qputenv (string varName, QByteArray value) |
More... | |
static void | Qsrand (uint seed) |
More... | |
static int | Qstrcmp (QByteArray str1, QByteArray str2) |
static int | Qstrcmp (QByteArray str1, string str2) |
static int | Qstrcmp (string str1, QByteArray str2) |
static int | Qstrcmp (string str1, string str2) |
More... | |
static Pointer< sbyte > | Qstrcpy (Pointer< sbyte > dst, string src) |
More... | |
static Pointer< sbyte > | Qstrdup (string src) |
More... | |
static int | Qstricmp (string str1, string str2) |
More... | |
static uint | Qstrlen (string str) |
More... | |
static int | Qstrncmp (string str1, string str2, uint len) |
More... | |
static Pointer< sbyte > | Qstrncpy (Pointer< sbyte > dst, string src, uint len) |
More... | |
static int | Qstrnicmp (string str1, string str2, uint len) |
More... | |
static uint | Qstrnlen (string str, uint maxlen) |
More... | |
Protected Member Functions | |
QUdpSocket (System.Type dummy) | |
![]() | |
QAbstractSocket (System.Type dummy) | |
new void | ConnectToHostImplementation (string hostName, ushort port, QIODevice.OpenModeFlag mode=QIODevice.OpenModeFlag.ReadWrite) |
More... | |
new void | OnConnected () |
More... | |
new void | DisconnectFromHostImplementation () |
More... | |
new void | OnDisconnected () |
More... | |
new void | OnError (QAbstractSocket.SocketError socketError) |
More... | |
new void | OnHostFound () |
More... | |
new void | OnProxyAuthenticationRequired (QNetworkProxy proxy, QAuthenticator authenticator) |
More... | |
override long | ReadData (Pointer< sbyte > data, long maxlen) |
More... | |
override long | ReadLineData (Pointer< sbyte > data, long maxlen) |
More... | |
new void | SetSocketError (QAbstractSocket.SocketError socketError) |
More... | |
new void | SetSocketState (QAbstractSocket.SocketState state) |
More... | |
new void | OnStateChanged (QAbstractSocket.SocketState socketState) |
More... | |
override long | WriteData (string data, long len) |
More... | |
![]() | |
QIODevice (System.Type dummy) | |
new void | OnAboutToClose () |
More... | |
new void | OnBytesWritten (long bytes) |
More... | |
new void | OnReadChannelFinished () |
More... | |
new void | OnReadyRead () |
More... | |
![]() | |
QObject (System.Type dummy) | |
virtual void | OnChildEvent (QChildEvent @event) |
More... | |
virtual void | ConnectNotify (string signal) |
More... | |
virtual void | OnCustomEvent (QEvent @event) |
More... | |
new void | OnDestroyed (QObject obj=null) |
More... | |
virtual void | DisconnectNotify (string signal) |
More... | |
new int | Receivers (string signal) |
More... | |
virtual void | OnTimerEvent (QTimerEvent @event) |
More... | |
Additional Inherited Members | |
![]() | |
</para > *< para > Creating QM files suitable for use with this[SmokeMethod("qtTrId(const char*, int)")] static strin | QtTrId )(string id, int n=-1) |
![]() | |
object | Q_EMIT = null |
SmokeInvocation | interceptor |
readonly List< QEventHandler > | eventFilters = new List<QEventHandler>() |
The QUdpSocket class provides a UDP socket.
UDP (User Datagram Protocol) is a lightweight, unreliable, datagram-oriented, connectionless protocol. It can be used when reliability isn't important. QUdpSocket is a subclass of QAbstractSocket that allows you to send and receive UDP datagrams.
The most common way to use this class is to bind to an address and port using bind(), then call writeDatagram() and readDatagram() to transfer data. If you want to use the standard QIODevice functions read(), readLine(), write(), etc., you must first connect the socket directly to a peer by calling connectToHost().
The socket emits the bytesWritten() signal every time a datagram is written to the network. If you just want to send datagrams, you don't need to call bind().
The readyRead() signal is emitted whenever datagrams arrive. In that case, hasPendingDatagrams() returns true. Call pendingDatagramSize() to obtain the size of the first pending datagram, and readDatagram() to read it.
Note: An incoming datagram should be read when you receive the readyRead() signal, otherwise this signal will not be emitted for the next datagram.
Example:
void Server::initSocket()
{
udpSocket = new QUdpSocket(this);
udpSocket->bind(QHostAddress::LocalHost, 7755);
connect(udpSocket, SIGNAL(readyRead()),
this, SLOT(readPendingDatagrams()));
}
void Server::readPendingDatagrams()
{
while (udpSocket->hasPendingDatagrams()) {
QByteArray datagram;
datagram.resize(udpSocket->pendingDatagramSize());
QHostAddress sender;
quint16 senderPort;
udpSocket->readDatagram(datagram.data(), datagram.size(),
&sender, &senderPort);
processTheDatagram(datagram);
}
}
QUdpSocket also supports UDP multicast. Use joinMulticastGroup() and leaveMulticastGroup() to control group membership, and QAbstractSocket::MulticastTtlOption and QAbstractSocket::MulticastLoopbackOption to set the TTL and loopback socket options. Use setMulticastInterface() to control the outgoing interface for multicast datagrams, and multicastInterface() to query it.
With QUdpSocket, you can also establish a virtual connection to a UDP server using connectToHost() and then use read() and write() to exchange datagrams without specifying the receiver for each datagram.
The Broadcast Sender, Broadcast Receiver, Multicast Sender, and Multicast Receiver examples illustrate how to use QUdpSocket in applications.
Symbian Platform Security Requirements
On Symbian, processes which use this class must have the NetworkServices platform security capability. If the client process lacks this capability, operations will result in a panic.
Platform security capabilities are added via the TARGET.CAPABILITY qmake variable.
See also QTcpSocket.
This enum describes the different flags you can pass to modify the behavior of QUdpSocket::bind().
Note: On Symbian OS bind flags behaviour depends on process capabilties. If process has NetworkControl capability, the bind attempt with ReuseAddressHint will always succeed even if the address and port is already bound by another socket with any flags. If process does not have NetworkControl capability, the bind attempt to address and port already bound by another socket will always fail.
This enum was introduced or modified in Qt 4.1.
Enumerator | |
---|---|
DefaultForPlatform |
The default option for the current platform. On Unix and Mac OS X, this is equivalent to (DontShareAddress + ReuseAddressHint), and on Windows, its equivalent to ShareAddress. |
DontShareAddress |
Bind the address and port exclusively, so that no other services are allowed to rebind. By passing this option to QUdpSocket::bind(), you are guaranteed that on successs, your service is the only one that listens to the address and port. No services are allowed to rebind, even if they pass ReuseAddressHint. This option provides more security than ShareAddress, but on certain operating systems, it requires you to run the server with administrator privileges. On Unix and Mac OS X, not sharing is the default behavior for binding an address and port, so this option is ignored. On Windows, this option uses the SO_EXCLUSIVEADDRUSE socket option. |
ReuseAddressHint |
Provides a hint to QUdpSocket that it should try to rebind the service even if the address and port are already bound by another socket. On Windows, this is equivalent to the SO_REUSEADDR socket option. On Unix, this option is ignored. |
ShareAddress |
Allow other services to bind to the same address and port. This is useful when multiple processes share the load of a single service by listening to the same address and port (e.g., a web server with several pre-forked listeners can greatly improve response time). However, because any service is allowed to rebind, this option is subject to certain security considerations. Note that by combining this option with ReuseAddressHint, you will also allow your service to rebind an existing shared address. On Unix, this is equivalent to the SO_REUSEADDR socket option. On Windows, this option is ignored. |
|
protected |
QtNetwork.QUdpSocket.QUdpSocket | ( | QObject | parent = null | ) |
Creates a QUdpSocket object.
parent is passed to the QObject constructor.
See also socketType().
new bool QtNetwork.QUdpSocket.Bind | ( | QHostAddress | address, |
ushort | port | ||
) |
Binds this socket to the address address and the port port. When bound, the signal readyRead() is emitted whenever a UDP datagram arrives on the specified address and port. This function is useful to write UDP servers.
On success, the functions returns true and the socket enters BoundState; otherwise it returns false.
The socket is bound using the DefaultForPlatform BindMode.
See also readDatagram().
new bool QtNetwork.QUdpSocket.Bind | ( | QHostAddress | address, |
ushort | port, | ||
QUdpSocket.BindFlag | mode | ||
) |
This is an overloaded function.
Binds to address on port port, using the BindMode mode.
This function was introduced in Qt 4.1.
new bool QtNetwork.QUdpSocket.Bind | ( | ushort | port = 0 | ) |
This is an overloaded function.
Binds to QHostAddress:Any on port port.
new bool QtNetwork.QUdpSocket.Bind | ( | ushort | port, |
QUdpSocket.BindFlag | mode | ||
) |
This is an overloaded function.
Binds to QHostAddress:Any on port port, using the BindMode mode.
This function was introduced in Qt 4.1.
|
virtual |
new void QtNetwork.QUdpSocket.Dispose | ( | ) |
new bool QtNetwork.QUdpSocket.JoinMulticastGroup | ( | QHostAddress | groupAddress | ) |
Joins the the multicast group specified by groupAddress on the default interface chosen by the operating system. The socket must be in BoundState, otherwise an error occurs.
This function returns true if successful; otherwise it returns false and sets the socket error accordingly.
This function was introduced in Qt 4.8.
See also leaveMulticastGroup().
new bool QtNetwork.QUdpSocket.JoinMulticastGroup | ( | QHostAddress | groupAddress, |
QNetworkInterface | iface | ||
) |
This is an overloaded function.
Joins the multicast group address groupAddress on the interface iface.
This function was introduced in Qt 4.8.
See also leaveMulticastGroup().
new bool QtNetwork.QUdpSocket.LeaveMulticastGroup | ( | QHostAddress | groupAddress | ) |
Leaves the multicast group specified by groupAddress on the default interface chosen by the operating system. The socket must be in BoundState, otherwise an error occurs.
This function returns true if successful; otherwise it returns false and sets the socket error accordingly.
This function was introduced in Qt 4.8.
See also joinMulticastGroup().
new bool QtNetwork.QUdpSocket.LeaveMulticastGroup | ( | QHostAddress | groupAddress, |
QNetworkInterface | iface | ||
) |
This is an overloaded function.
Leaves the multicast group specified by groupAddress on the interface iface.
This function was introduced in Qt 4.8.
See also joinMulticastGroup().
new long QtNetwork.QUdpSocket.ReadDatagram | ( | Pointer< sbyte > | data, |
long | maxlen, | ||
QHostAddress | host = null |
||
) |
Receives a datagram no larger than maxSize bytes and stores it in data. The sender's host address and port is stored in *address and *port (unless the pointers are 0).
Returns the size of the datagram on success; otherwise returns -1.
If maxSize is too small, the rest of the datagram will be lost. To avoid loss of data, call pendingDatagramSize() to determine the size of the pending datagram before attempting to read it. If maxSize is 0, the datagram will be discarded.
See also writeDatagram(), hasPendingDatagrams(), and pendingDatagramSize().
new long QtNetwork.QUdpSocket.ReadDatagram | ( | Pointer< sbyte > | data, |
long | maxlen, | ||
QHostAddress | host, | ||
ref ushort | port | ||
) |
Receives a datagram no larger than maxSize bytes and stores it in data. The sender's host address and port is stored in *address and *port (unless the pointers are 0).
Returns the size of the datagram on success; otherwise returns -1.
If maxSize is too small, the rest of the datagram will be lost. To avoid loss of data, call pendingDatagramSize() to determine the size of the pending datagram before attempting to read it. If maxSize is 0, the datagram will be discarded.
See also writeDatagram(), hasPendingDatagrams(), and pendingDatagramSize().
|
static |
|
static |
|
static |
|
static |
new long QtNetwork.QUdpSocket.WriteDatagram | ( | QByteArray | datagram, |
QHostAddress | host, | ||
ushort | port | ||
) |
This is an overloaded function.
Sends the datagram datagram to the host address host and at port port.
new long QtNetwork.QUdpSocket.WriteDatagram | ( | string | data, |
long | len, | ||
QHostAddress | host, | ||
ushort | port | ||
) |
Sends the datagram at data of size size to the host address address at port port. Returns the number of bytes sent on success; otherwise returns -1.
Datagrams are always written as one block. The maximum size of a datagram is highly platform-dependent, but can be as low as 8192 bytes. If the datagram is too large, this function will return -1 and error() will return DatagramTooLargeError.
Sending datagrams larger than 512 bytes is in general disadvised, as even if they are sent successfully, they are likely to be fragmented by the IP layer before arriving at their final destination.
Warning: In S60 5.0 and earlier versions, the writeDatagram return value is not reliable for large datagrams.
Warning: Calling this function on a connected UDP socket may result in an error and no packet being sent. If you are using a connected socket, use write() to send datagrams.
See also readDatagram() and write().
|
getprotected |
|
get |
Returns true if at least one datagram is waiting to be read; otherwise returns false.
See also pendingDatagramSize() and readDatagram().
|
getset |
Returns the interface for the outgoing interface for multicast datagrams. This corresponds to the IP_MULTICAST_IF socket option for IPv4 sockets and the IPV6_MULTICAST_IF socket option for IPv6 sockets. If no interface has been previously set, this function returns an invalid QNetworkInterface. The socket must be in BoundState, otherwise an invalid QNetworkInterface is returned.
This function was introduced in Qt 4.8.
Sets the outgoing interface for multicast datagrams to the interface iface. This corresponds to the IP_MULTICAST_IF socket option for IPv4 sockets and the IPV6_MULTICAST_IF socket option for IPv6 sockets. The socket must be in BoundState, otherwise this function does nothing.
This function was introduced in Qt 4.8.
|
get |
Returns the size of the first pending UDP datagram. If there is no datagram available, this function returns -1.
See also hasPendingDatagrams() and readDatagram().
|
staticget |