Can anyone help explain what an errno value of ENOENT means when the bind() socket function fails? The man page says this means "the file does not exist". What file? I tried calling bind() with a bad file descriptor and that sets errno to EBADF as expected, so it's not that.
A:
This is almost certainly a bug in your code. If I had to guess, which I do, I'd say you've got a bad UNIX socket path in the address you pass to bind.
It is also possible that the error code isn't coming from bind - check your thread safety.
Borealid
2010-08-04 18:03:04
Unfortunately, I cannot post the actual code. It is spread across 4 classes in a large, object-oriented system. I tried passing an explicitly bad address to bind and got EFAULT. Passing a bad size (3rd arg) gives EINVAL. I also located the kernel source and cannot yet find where any of the bind() code could return ENOENT.
Mike Jones
2010-08-05 12:40:06
Ah, got it - answer edited. This one's actually the problem :-). Sorry it took so long to figure it out.
Borealid
2010-08-05 14:57:01
Found the problem, but still don't understand where the ENOENT came from. Long story, but we were using the wrong IP address going into the bind() call, which should have set errno to EADDRNOTAVAIL. So the ENOENT sent me off on a wild goose chase. Thanks for prodding my thinking along. :)
Mike Jones
2010-08-05 16:11:44