I am working on an application that uses UDP port 6785 to detect network-connected data loggers. My application is trying to call bind () as follows:
int socket_handle;
int error = 0;
socket_handle = socket(AF_INET, SOCK_DGRAM, 0);
if(socket_handle < 0)
error = errno;
if(error == 0)
{
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_len = sizeof(addr);
addr.sin_family = AF_INET;
addr.sin_port = htons(6785);
addr.sin_addr.s_addr = htonl(INADDR_ANY);
error = bind(socket_handle, (struct sockaddr const *)&addr, sizeof(addr));
}
The error returned by the bind () function is error 49 (cannot assign the requested address). Is this due to a conflict with any internal device or is the OS blocked for an unknown reason?
It turns out that the crash does not occur if I disabled the VPN. I had to turn on a VPN to access our local network with Wi-Fi.
source
share