English 中文(简体)
如何选择网络的接口以使用?
原标题:How to choose which Network interface to use?

我用Qt来进行我的肺结核病通报。 如果我的PC有2个网络接口(say eth0, eth1),而且我要明确使用伦理1,我如何在Qt这样做?

最佳回答

QTcpServer:listen在你希望听取意见的界面上发言,这是第一个论点。

如果您有关于伦理学的第192.168.0.1和10.0.0.1号文件,则

QTcpServer serv0;
QTcpServer serv1;

serv0.listen( QHostAddress("192.168.0.1"), 8080 );
serv1.listen( QHostAddress("10.0.0.1"), 8080 );

SER0将只听8080港的伦理学,SER1只听8080港的伦理学。

无法确定哪些接口应当使用QTcpSocket,因为根据Ckernel routing表,这一接口由操作系统决定。

你可以使用QNetworkInterface:all Addresses()获得接口地址清单。

问题回答

这并不是一个问题。 Bind() to the Address on >。 希望你能这样做。

如果必须使用接口名称而不是IP,则请使用静态功能<代码>QNetworkInterace:interfaceFromName,并检查其地址和状态。 然后,利用Info来启动袖珍或服务器。





相关问题
Qt: Do events get processed in order?

If I had a class A, where one of its functions does: void A::func() { emit first_signal(); emit second_signal(); } Assuming that a class B has 2 slots, one connected to first_signal, and the ...

How to determine how much free space on a drive in Qt?

I m using Qt and want a platform-independent way of getting the available free disk space. I know in Linux I can use statfs and in Windows I can use GetDiskFreeSpaceEx(). I know boost has a way, ...

Drag & drop with .ui files

I m having big troubles with drag & drop. I ve created a new Qt Designer Form Class in which I have one QListWidget and one QWidget. Now I want to enable dragging & dropping between these two ...

Link errors on Snow Leopard

I creating a small desktop application using Qt and Poco on Mac OS X Snow Leopard. Qt works fine, but once I started linking with Poco I get the following warning: ld: warning: in /Developer/SDKs/...

Showing two windows in Qt4

My friend and I have each created parts of a GUI using Qt 4. They both work independently and I am trying to integrate his form with the my main window. As of now this is the code I am using to try ...

Qt equivalent of .NET data binding?

Is there an equivalent of .NET s data binding in Qt? I want to populate some combo boxes and other widgets with QStrings that refer to specific entities in my database. However, it would be cleaner ...

热门标签