Hello,
I have a socket app performing recvfrom(...) on a UDP socket. The data comes across fine, but I don't get an IP address in the sockaddr struct, although I do get a port... Code:
inet_ntoa(sourceAddr.sin_addr) gives "0.0.0.0"
ntohs(sourceAddr.sin_port) gives "50717" (or whatever the remote port was, varies of course).
This is running on a Linux box with g++ 4.1.1, and the problem happens with UDP packets sent from either another Linux machine or Windows.
I also notice that when I bind this UDP port, it thinks it's IP address is also 0.0.0.0, although when I bind TCP sockets elsewhere in the app, they correctly determine the machine's IP.
Any ideas?
Thanks,
Dan
I have a socket app performing recvfrom(...) on a UDP socket. The data comes across fine, but I don't get an IP address in the sockaddr struct, although I do get a port... Code:
Code:
sockaddr_in sourceAddr;
socklen_t addrLen;
recvfrom(socketfd, buffer, avail, 0, (sockaddr*)&sourceAddr, &addrLen);
inet_ntoa(sourceAddr.sin_addr) gives "0.0.0.0"
ntohs(sourceAddr.sin_port) gives "50717" (or whatever the remote port was, varies of course).
This is running on a Linux box with g++ 4.1.1, and the problem happens with UDP packets sent from either another Linux machine or Windows.
I also notice that when I bind this UDP port, it thinks it's IP address is also 0.0.0.0, although when I bind TCP sockets elsewhere in the app, they correctly determine the machine's IP.
Any ideas?
Thanks,
Dan