Alex Foglia
Alex Foglia

Reputation: 530

QUdpSocket bind failed

I'm having an issue with QT Udp sockets. Assuming all headers are correctly included, I'm writing:

QUdpSocket* s = new QUdpSocket();
bool ok = s->bind(QHostAddress::Any, 8081);
if(!ok)
{
    std::cout << "Cannot bind socket: " << s->errorString().toStdString() << std::endl;
}

The output is always Cannot bind socket: operation is not supported

I made several attempts to solve this: tried disabling firewall, tried to bind specifing only the port, searching in internet, but the problem still remain.

My architecture is AMD64, Windows 7 installed

Upvotes: 2

Views: 1646

Answers (1)

Alex Foglia
Alex Foglia

Reputation: 530

It is a platform specific issue, since a UnsupportedSocketOperationError is thrown.

/* 10 */ 
\value UnsupportedSocketOperationError The requested socket operation is
       not supported by the local operating system (e.g., lack of
       IPv6 support).

I solved by adding:

s->setProxy(QNetworkProxy::NoProxy);

before calling s->bind().

Upvotes: 3

Related Questions