tags:

views:

230

answers:

2

I have an application that is being built using Qt. It will be running on machines that will have two (or more) network cards. I need the ability for my application to select which ethernet interfaces for a TCP connection. Before anyone suggests it I cannot guarenteed that routing tables will be setup correctly. I know how to do this using the windows socket classes but have been unable to find anything about it for Qt. Any help would be greatly appreciated!

A: 

If you are using Qt 4.2 or later, you can use QNetworkInterface to get a list of network interfaces in the computer and then create some sort of network interface selection.

nmuntz
I'm not having an issue finding out which interfaces are available. My question is how do I force the QTcpSocket class to use a specific interface.
NJChim
+3  A: 

Are you referring to an outbound connection or an inbound connection?

If you're referring to an inbound connection, all you need to do is specify a QHostAddress to the QTcpServer::listen call.

If you're talking about an outbound connection, you can call QAbstractSocket::setLocalAddress to force the local address to something specific.

Cheers,

Thomi