tags:

views:

29

answers:

1

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
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
Ah, got it - answer edited. This one's actually the problem :-). Sorry it took so long to figure it out.
Borealid
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