Bind QWebSocket & QNetworkAccessManager to specific local Interface/IP?
-
wrote on 28 Aug 2019, 12:19 last edited by Taytoo
Is there any way to bind QWebsocket & QNetworkAccessManager to a specific local IP?
For QWebSocket, the only option I see is an undocumented constructor for QWebSocket which takes pQTcpSocket.
QWebSocket(QTcpSocket *pTcpSocket, QWebSocketProtocol::Version version, QObject *pParent);
One could theoretically create a QTcpSocket, bind it to specific IP and then pass it to websocket constructor. Would that work? Any possible issues with this?
Couldn't find any possible way of doing the same for QNetworkAccessManager. Any ideas?
-
wrote on 28 Aug 2019, 13:27 last edited by
Update: Tried passing QTcpSocket to QWebSocket constructor but compiler is giving "cannot access private member" error.
-
What's wrong with QWebSocketServer::listen()?
-
What's wrong with QWebSocketServer::listen()?
wrote on 29 Aug 2019, 06:01 last edited by@christian-ehrlicher Its a client websocket. I want to bind client socket to a specific local interface/IP e.g. if a computer has two network cards, wifi and ethernet, and user wants software(websocket) to use ethernet interface for all communications.
-
This is currently not supported with QWebSocket
-
This is currently not supported with QWebSocket
wrote on 29 Aug 2019, 06:27 last edited by Taytoo@christian-ehrlicher I'm building static Qt myself. If I just add a bind method to QWebSocket and forward that call to internal pTcpSocket, would that be ok?
Can I submit this change for inclusion into Qt code?
-
@christian-ehrlicher I'm building static Qt myself. If I just add a bind method to QWebSocket and forward that call to internal pTcpSocket, would that be ok?
Can I submit this change for inclusion into Qt code?
@taytoo said in Bind QWebSocket & QNetworkAccessManager to specific local Interface/IP?:
@christian-ehrlicher I'm building static Qt myself. If I just add a bind method to QWebSocket and forward that call to internal pTcpSocket, would that be ok?
Can I submit this change for inclusion into Qt code?
I'm not the maintainter of QWebSocket, but I think the answer to both questions is yes.
Have a look at https://wiki.qt.io/Qt_Contribution_Guidelines to get started with your contribution.
Regards
-
I would add something like QWebSocket::setBindAddress(const QHostAddress &address, quint16 port = 0, QAbstractSocket::BindMode mode = DefaultForPlatform) which could then be used in QWebSocketPrivate::open()
1/8