diff options
Diffstat (limited to 'src/network/socket/qudpsocket.cpp')
-rw-r--r-- | src/network/socket/qudpsocket.cpp | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp index 009ce92d8e..79083e489a 100644 --- a/src/network/socket/qudpsocket.cpp +++ b/src/network/socket/qudpsocket.cpp @@ -108,51 +108,6 @@ \sa QTcpSocket */ -/*! \enum QUdpSocket::BindFlag - \since 4.1 - - 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. - - \value 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. - - \value 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. - - \value 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. - - \value 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. -*/ - #include "qhostaddress.h" #include "qnetworkinterface.h" #include "qabstractsocket_p.h" @@ -224,111 +179,6 @@ QUdpSocket::~QUdpSocket() { } -/*! - Binds this socket to the address \a address and the port \a 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. - - \sa readDatagram() -*/ -bool QUdpSocket::bind(const QHostAddress &address, quint16 port) -{ - Q_D(QUdpSocket); - if (!d->ensureInitialized(address, port)) - return false; - - bool result = d_func()->socketEngine->bind(address, port); - d->cachedSocketDescriptor = d->socketEngine->socketDescriptor(); - - if (!result) { - d->socketError = d_func()->socketEngine->error(); - setErrorString(d_func()->socketEngine->errorString()); - emit error(d_func()->socketError); - return false; - } - - d->state = BoundState; - d->localAddress = d->socketEngine->localAddress(); - d->localPort = d->socketEngine->localPort(); - - emit stateChanged(d_func()->state); - d_func()->socketEngine->setReadNotificationEnabled(true); - return true; -} - -/*! - \since 4.1 - \overload - - Binds to \a address on port \a port, using the BindMode \a mode. -*/ -bool QUdpSocket::bind(const QHostAddress &address, quint16 port, BindMode mode) -{ - Q_D(QUdpSocket); - if (!d->ensureInitialized(address, port)) - return false; - -#ifdef Q_OS_UNIX - if ((mode & ShareAddress) || (mode & ReuseAddressHint)) - d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1); - else - d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0); -#endif -#ifdef Q_OS_WIN - if (mode & ReuseAddressHint) - d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1); - else - d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0); - if (mode & DontShareAddress) - d->socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 1); - else - d->socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 0); -#endif - bool result = d_func()->socketEngine->bind(address, port); - d->cachedSocketDescriptor = d->socketEngine->socketDescriptor(); - - if (!result) { - d->socketError = d_func()->socketEngine->error(); - setErrorString(d_func()->socketEngine->errorString()); - emit error(d_func()->socketError); - return false; - } - - d->state = BoundState; - d->localAddress = d->socketEngine->localAddress(); - d->localPort = d->socketEngine->localPort(); - - emit stateChanged(d_func()->state); - d_func()->socketEngine->setReadNotificationEnabled(true); - return true; -} - -/*! \overload - - Binds to QHostAddress:Any on port \a port. -*/ -bool QUdpSocket::bind(quint16 port) -{ - return bind(QHostAddress::Any, port); -} - -/*! - \since 4.1 - \overload - - Binds to QHostAddress:Any on port \a port, using the BindMode \a mode. -*/ -bool QUdpSocket::bind(quint16 port, BindMode mode) -{ - return bind(QHostAddress::Any, port, mode); -} - #ifndef QT_NO_NETWORKINTERFACE /*! |