QUdpSocket Class Reference |
Constant | Value | Description |
---|---|---|
QUdpSocket::ShareAddress | 0x1 | 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. |
QUdpSocket::DontShareAddress | 0x2 | 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. |
QUdpSocket::ReuseAddressHint | 0x4 | 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. |
QUdpSocket::DefaultForPlatform | 0x0 | 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. |
This enum was introduced in Qt 4.1.
The BindMode type is a typedef for QFlags<BindFlag>. It stores an OR combination of BindFlag values.
Creates a QUdpSocket object.
parent is passed to the QObject constructor.
See also socketType().
Destroys the socket, closing the connection if necessary.
See also close().
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().
This is an overloaded member function, provided for convenience.
Binds to address on port port, using the BindMode mode.
This function was introduced in Qt 4.1.
This is an overloaded member function, provided for convenience.
Binds to QHostAddress:Any on port port.
This is an overloaded member function, provided for convenience.
Binds to QHostAddress:Any on port port, using the BindMode mode.
This function was introduced in Qt 4.1.
Returns true if at least one datagram is waiting to be read; otherwise returns false.
See also pendingDatagramSize() and readDatagram().
Returns the size of the first pending UDP datagram. If there is no datagram available, this function returns -1.
See also hasPendingDatagrams() and readDatagram().
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().
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.
See also readDatagram().
This is an overloaded member function, provided for convenience.
Sends the datagram datagram to the host address host and at port port.
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.1 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com