Is there any link or material where I can learn more about the different error numbers in Linux ??
At present in man errno I get a single line for each error number but I would like to know the conditions or chances for which particular error occurs (A more detailed description in short words)
For e.g.
EADDRNOTAVAIL 99 /* Cannot assign requested address */
Above error occurs when a socket tried to bind to ip-address which is not present locally in the machine .. Similarly for all other errors is there any wiki or material for detailed information ??
Well, since errors generally occur while doing something, your best bet is to look up the man
page for "something".
For example, if you get back an errno
of 34 from your fscanf()
call, you would first do:
grep 34 $(find /usr/include -name '*errno*h')
to figure out what the error was:
/usr/include/bits/errno.h:#define ERANGE 34 /* Math result not representable. */
/usr/include/asm-generic/errno-base.h:#define ERANGE 34 /* Math result not ... */
Then, looking at the man
page for fscanf()
, you see:
ERANGE - The result of an integer conversion would exceed the size
that can be stored in the corresponding integer type.
and you would (hopefully) be able to figure it out from there.
If you want a list of the errors and (brief) description, modify the grep
above as follows:
grep define $(find /usr/include -name '*errno*h') | less
and browse the output.
And, if you still don't know about the error and what caused it (the descriptions are a little terse, I'll agree), I would just bung it (e.g., EADDRNOTAVAIL
) into that little dialog box in the top right corner of your browser1 and you'll get back something like this (or many other wonderful pages):
Cannot assign requested address
You are attempting tobind(2)
to a local address that isn't local. For example if the IP addresses of a machine are127.0.0.1
and1.2.3.4
and you're trying to bind to1.2.3.5
, you are going to get this error. Check to make sure the address you are trying to bind to exists on the machine you are trying to bind it from.
This error can also come up if you're doing a "pre-bound connect", where you're first binding to a local port, then doing an outbound connect with a socket. If the local port is already connected to the given remote IP and port (i.e., there's already an identical socketpair), you'll receive this error (value = 99 on Linux).
4 pages link toEADDRNOTAVAIL
:
- bind(2)
- connect(2)
- setsockopt(2)
- packet(7)
Go ahead, try it with other error values as well, it's not too bad.
1 You are using Firefox, right? :-)
Error codes are fairly generic, and are meaningful only within the context of a particular function. So there isn't much advantage in learning all the error codes, as they may mean subtly different things for different functions and have to be handled differently anyway.
"ERRORS" section in the function's man page will tell you what codes are possible for its return values or errno
and why they occur.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With