views:

331

answers:

2

I'm getting errno==49 (EADDRNOTAVAIL) when trying to UDP-bind() to 127.0.0.1:47346 running Mac OS X on a G5 (big endian PowerPC). Is there something preventing me from doing so? I've tried other addresses and ports (192.168.1.2 and port 47346) but with no success.

Here's a gdb printout of my sockaddr_in:

$1 = {
  sin_len = 0 '\0', 
  sin_family = 2 '\002', 
  sin_port = 47346, 
  sin_addr = {
    s_addr = 3232235778
  }, 
  sin_zero = "???\000\000??"
}
+4  A: 

Hi,

You should fill the sin_len field as well (with sizeof(struct sockaddr_in), that should do the trick). This field is not appearing on each platform, but on which it exists, it must be filled.

Futhermore, be sure to bzero the structure before using it (but it clearly seems you did it anyway).

Patrick MARIE
Thanks a gazillion!
Jonas Byström
A: 

Thanks for the answer, I'm not sure if it was the bzero-ing or filling in the len field, but this fixed my issue. I'm no a Mac running 10.6 btw.

William Dillon