I'm attempting to determine the IP address that is used for broadcasting an
UDP packet. This seemed pretty straightforward but I always get 0.0.0.0
returned for my current IP address. I searched in the mailing list archive
and found this message from Francois :

> Use TWSocket.GetSockName once the connection is established to get both IP
and port
> Use GetXAddr and/or GetXPort to get only IP or port (easier because you
get as a string).

Using GetXAddr is what I did, but for some reason it fails to work and
always returns 0.0.0.0. 

MySocket->Proto="udp";
MySocket->Addr="255.255.255.255";
MySocket->LocalPort=5788;
MySocket->Port=5789;
MySocket->Connect();
DEBUG("LocalAddr=>[%s]",MySocket->LocalAddr.c_str());
DEBUG("GetXAddr=>[%s]",MySocket->GetXAddr().c_str());
MySocket->Send(Message.c_str(),Message.Length());

My PC's IP is 10.0.0.39. However, I get following output:
LocalAddr=>[0.0.0.0]
GetXAddr=>[0.0.0.0]

Using WireShark's network capturing I can confirm that the UDP is sent
correctly.

Src: 10.0.0.39 (10.0.0.39), Dst: 255.255.255.255 (255.255.255.255)
User Datagram Protocol, Src Port: 5788 (5788), Dst Port: 5789 (5789)

Can someone help me out with determining the IP address that is used to send
the UDP packet.

Thanks,

Kris


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to