⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 library_2.html

📁 Linux程序员的工作手册
💻 HTML
📖 第 1 页 / 共 2 页
字号:
An operation that cannot complete immediately was initiated on an objectthat has non-blocking mode selected.<P><A NAME="IDX87"></A><U>Macro:</U> int <B>EALREADY</B><P>An operation is already in progress on an object that has non-blockingmode selected.<P><A NAME="IDX88"></A><U>Macro:</U> int <B>ENOTSOCK</B><P>A file that isn't a socket was specified when a socket is required.<P><A NAME="IDX89"></A><U>Macro:</U> int <B>EDESTADDRREQ</B><P>No destination address was supplied on a socket operation.<P><A NAME="IDX90"></A><U>Macro:</U> int <B>EMSGSIZE</B><P>The size of a message sent on a socket was larger than the supportedmaximum size.  <P><A NAME="IDX91"></A><U>Macro:</U> int <B>EPROTOTYPE</B><P>The socket type does not support the requested communications protocol.<P><A NAME="IDX92"></A><U>Macro:</U> int <B>ENOPROTOOPT</B><P>You specified a socket option that doesn't make sense for theparticular protocol being used by the socket.  See section <A HREF="library_15.html#SEC264" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC264">Socket Options</A>.<P><A NAME="IDX93"></A><U>Macro:</U> int <B>EPROTONOSUPPORT</B><P>The socket domain does not support the requested communications protocol.See section <A HREF="library_15.html#SEC241" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC241">Creating a Socket</A>.<P><A NAME="IDX94"></A><U>Macro:</U> int <B>ESOCKTNOSUPPORT</B><P>The socket type is not supported.<P><A NAME="IDX95"></A><U>Macro:</U> int <B>EOPNOTSUPP</B><P>The operation you requested is not supported.  Some socket functionsdon't make sense for all types of sockets, and others may not be implementedfor all communications protocols.<P><A NAME="IDX96"></A><U>Macro:</U> int <B>EPFNOSUPPORT</B><P>The socket communications protocol family you requested is not supported.<P><A NAME="IDX97"></A><U>Macro:</U> int <B>EAFNOSUPPORT</B><P>The address family specified for a socket is not supported; it isinconsistent with the protocol being used on the socket.  See section <A HREF="library_15.html#SEC216" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC216">Sockets</A>.<P><A NAME="IDX98"></A><U>Macro:</U> int <B>EADDRINUSE</B><P>The requested socket address is already in use.  See section <A HREF="library_15.html#SEC219" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC219">Socket Addresses</A>.<P><A NAME="IDX99"></A><U>Macro:</U> int <B>EADDRNOTAVAIL</B><P>The requested socket address is not available; for example, you triedto give a socket a name that doesn't match the local host name.See section <A HREF="library_15.html#SEC219" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC219">Socket Addresses</A>.<P><A NAME="IDX100"></A><U>Macro:</U> int <B>ENETDOWN</B><P>A socket operation failed because the network was down.<P><A NAME="IDX101"></A><U>Macro:</U> int <B>ENETUNREACH</B><P>A socket operation failed because the subnet containing the remost hostwas unreachable.<P><A NAME="IDX102"></A><U>Macro:</U> int <B>ENETRESET</B><P>A network connection was reset because the remote host crashed.<P><A NAME="IDX103"></A><U>Macro:</U> int <B>ECONNABORTED</B><P>A network connection was aborted locally.<P><A NAME="IDX104"></A><U>Macro:</U> int <B>ECONNRESET</B><P>A network connection was closed for reasons outside the control of thelocal host, such as by the remote machine rebooting.<P><A NAME="IDX105"></A><U>Macro:</U> int <B>ENOBUFS</B><P>The kernel's buffers for I/O operations are all in use.<P><A NAME="IDX106"></A><U>Macro:</U> int <B>EISCONN</B><P>You tried to connect a socket that is already connected.See section <A HREF="library_15.html#SEC245" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC245">Making a Connection</A>.<P><A NAME="IDX107"></A><U>Macro:</U> int <B>ENOTCONN</B><P>The socket is not connected to anything.  You get this error when youtry to transmit data over a socket, without first specifying a destinationfor the data.<P><A NAME="IDX108"></A><U>Macro:</U> int <B>ESHUTDOWN</B><P>The socket has already been shut down.<P><A NAME="IDX109"></A><U>Macro:</U> int <B>ETIMEDOUT</B><P>A socket operation with a specified timeout received no response duringthe timeout period.<P><A NAME="IDX110"></A><U>Macro:</U> int <B>ECONNREFUSED</B><P>A remote host refused to allow the network connection (typically becauseit is not running the requested service).<P><A NAME="IDX111"></A><U>Macro:</U> int <B>ELOOP</B><P>Too many levels of symbolic links were encountered in looking up a file name.This often indicates a cycle of symbolic links.<P><A NAME="IDX112"></A><U>Macro:</U> int <B>ENAMETOOLONG</B><P>Filename too long (longer than <CODE>PATH_MAX</CODE>; see section <A HREF="library_27.html#SEC463" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC463">Limits on File System Capacity</A>) or host name too long (in <CODE>gethostname</CODE> or<CODE>sethostname</CODE>; see section <A HREF="library_26.html#SEC452" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_26.html#SEC452">Host Identification</A>).<P><A NAME="IDX113"></A><U>Macro:</U> int <B>EHOSTDOWN</B><P>The remote host for a requested network connection is down.<P><A NAME="IDX114"></A><U>Macro:</U> int <B>EHOSTUNREACH</B><P>The remote host for a requested network connection is not reachable.<P><A NAME="IDX115"></A><U>Macro:</U> int <B>ENOTEMPTY</B><P>Directory not empty, where an empty directory was expected.  Typically,this error occurs when you are trying to delete a directory.<P><A NAME="IDX116"></A><U>Macro:</U> int <B>EUSERS</B><P>The file quota system is confused because there are too many users.<P><A NAME="IDX117"></A><U>Macro:</U> int <B>EDQUOT</B><P>The user's disk quota was exceeded.<P><A NAME="IDX118"></A><U>Macro:</U> int <B>ESTALE</B><P>Stale NFS file handle.  This indicates an internal confusion in the NFSsystem which is due to file system rearrangements on the server host.Repairing this condition usually requires unmounting and remountingthe NFS file system on the local host.<P><A NAME="IDX119"></A><U>Macro:</U> int <B>EREMOTE</B><P>An attempt was made to NFS-mount a remote file system with a file name thatalready specifies an NFS-mounted file.(This is an error on some operating systems, but we expect it to workproperly on the GNU system, making this error code impossible.)<P><A NAME="IDX120"></A><U>Macro:</U> int <B>ENOLCK</B><P>No locks available.  This is used by the file locking facilities;see section <A HREF="library_12.html#SEC185" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html#SEC185">File Locks</A>.<P><A NAME="IDX121"></A><U>Macro:</U> int <B>ENOSYS</B><P>Function not implemented.  Some functions have commands or options definedthat might not be supported in all implementations, and this is the kindof error you get if you request them and they are not supported.<P><A NAME="IDX122"></A><U>Macro:</U> int <B>ED</B><P>The experienced user will know what is wrong.<P><A NAME="IDX123"></A><U>Macro:</U> int <B>EGRATUITOUS</B><P>This error code has no purpose.<P><H2><A NAME="SEC17" HREF="library_toc.html#SEC17" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC17">Error Messages</A></H2><P>The library has functions and variables designed to make it easy foryour program to report informative error messages in the customaryformat about the failure of a library call.  The functions<CODE>strerror</CODE> and <CODE>perror</CODE> give you the standard error messagefor a given error code; the variable<CODE>program_invocation_short_name</CODE> gives you convenient access to thename of the program that encountered the error.<P><A NAME="IDX124"></A><U>Function:</U> char * <B>strerror</B> <I>(int <VAR>errnum</VAR>)</I><P>The <CODE>strerror</CODE> function maps the error code (see section <A HREF="library_2.html#SEC15" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_2.html#SEC15">Checking for Errors</A>) specified by the <VAR>errnum</VAR> argument to a descriptive errormessage string.  The return value is a pointer to this string.<P>The value <VAR>errnum</VAR> normally comes from the variable <CODE>errno</CODE>.<P>You should not modify the string returned by <CODE>strerror</CODE>.  Also, ifyou make subsequent calls to <CODE>strerror</CODE>, the string might beoverwritten.  (But it's guaranteed that no library function ever calls<CODE>strerror</CODE> behind your back.)<P>The function <CODE>strerror</CODE> is declared in <TT>`string.h'</TT>.<P><A NAME="IDX125"></A><U>Function:</U> void <B>perror</B> <I>(const char *<VAR>message</VAR>)</I><P>This function prints an error message to the stream <CODE>stderr</CODE>;see section <A HREF="library_11.html#SEC119" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC119">Standard Streams</A>.<P>If you call <CODE>perror</CODE> with a <VAR>message</VAR> that is either a nullpointer or an empty string, <CODE>perror</CODE> just prints the error message corresponding to <CODE>errno</CODE>, adding a trailing newline.<P>If you supply a non-null <VAR>message</VAR> argument, then <CODE>perror</CODE>prefixes its output with this string.  It adds a colon and a space character to separate the <VAR>message</VAR> from the error string correspondingto <CODE>errno</CODE>.<P>The function <CODE>perror</CODE> is declared in <TT>`stdio.h'</TT>.<P><CODE>strerror</CODE> and <CODE>perror</CODE> produce the exact same message for anygiven error code; the precise text varies from system to system.  On theGNU system, the messages are fairly short; there are no multi-linemessages or embedded newlines.  Each error message begins with a capitalletter and does not include any terminating punctuation.<P><STRONG>Compatibility Note:</STRONG>  The <CODE>strerror</CODE> function is a newfeature of ANSI C.  Many older C systems do not support this functionyet.<A NAME="IDX126"></A><A NAME="IDX127"></A><P>Many programs that don't read input from the terminal are designed toexit if any system call fails.  By convention, the error message fromsuch a program should start with the program's name, sans directories.You can find that name in the variable<CODE>program_invocation_short_name</CODE>; the full file name is stored thevariable <CODE>program_invocation_name</CODE>:<P><A NAME="IDX128"></A><U>Variable:</U> char * <B>program_invocation_name</B><P>This variable's value is the name that was used to invoke the programrunning in the current process.  It is the same as <CODE>argv[0]</CODE>.<P><A NAME="IDX129"></A><U>Variable:</U> char * <B>program_invocation_short_name</B><P>This variable's value is the name that was used to invoke the programrunning in the current process, with directory names removed.  (That isto say, it is the same as <CODE>program_invocation_name</CODE> minuseverything up to the last slash, if any.)<P>Both <CODE>program_invocation_name</CODE> and<CODE>program_invocation_short_name</CODE> are set up by the system before<CODE>main</CODE> is called.<P><STRONG>Portability Note:</STRONG> These two variables are GNU extensions.  Ifyou want your program to work with non-GNU libraries, you must save thevalue of <CODE>argv[0]</CODE> in <CODE>main</CODE>, and then strip off the directorynames yourself.  We added these extensions to make it possible to writeself-contained error-reporting subroutines that require no explicitcooperation from <CODE>main</CODE>.<P>Here is an example showing how to handle failure to open a filecorrectly.  The function <CODE>open_sesame</CODE> tries to open the named filefor reading and returns a stream if successful.  The <CODE>fopen</CODE>library function returns a null pointer if it couldn't open the file forsome reason.  In that situation, <CODE>open_sesame</CODE> constructs anappropriate error message using the <CODE>strerror</CODE> function, andterminates the program.  If we were going to make some other librarycalls before passing the error code to <CODE>strerror</CODE>, we'd have tosave it in a local variable instead, because those other libraryfunctions might overwrite <CODE>errno</CODE> in the meantime.<P><PRE>#include &#60;errno.h&#62;#include &#60;stdio.h&#62;#include &#60;stdlib.h&#62;#include &#60;string.h&#62;FILE *open_sesame (char *name){   FILE *stream;  errno = 0;                       stream = fopen (name, "r");  if (!stream) {    fprintf (stderr, "%s: Couldn't open file %s; %s\n",             program_invocation_short_name, name, strerror (errno));    exit (EXIT_FAILURE);  } else    return stream;}</PRE><P><P>Go to the <A HREF="library_1.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_1.html">previous</A>, <A HREF="library_3.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_3.html">next</A> section.<P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -