짧은 대답은 bind to *one of the addresses of the eth interface입니다.
Qt는 꽤 끔찍하게 깨끗합니다. library for this. 그러나 내가 더러운 것을 내려야 할 때는 ACE C++ library과 같은 것을 사용할 것입니다.
어쨌든, 여기 당신이 시작하는 일이다, 그러나 당신은보다 구체적인 QtCreator에서 예 또는 google에 표시되어야합니다
QUdpSocket socket;
// I am using the eth interface that's associated
// with IP 192.168.1.77
//
// Note that I'm using a "random" (ephemeral) port by passing 0
if(socket.bind(QHostAddress("192.168.1.77"), 0))
{
// Send it out to some IP (192.168.1.1) and port (45354).
qint64 bytesSent = socket.writeDatagram(QByteArray("Hello World!"),
QHostAddress("192.168.1.1"),
45354);
// ... etc ...
}
출처
2013-06-21 20:05:52
Huy