Linux Sockets Error Codes
Contents |
Aug 2004 on RedHat 7.3 #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ #define EINTR 4 /* Interrupted system call */ #define EIO 5 /* I/O linux errno example error */ #define ENXIO 6 /* No such device or address */ #define E2BIG 7 /*
Errno.h In C
Arg list too long */ #define ENOEXEC 8 /* Exec format error */ #define EBADF 9 /* Bad file number */ #define ECHILD 10 /* errno.h windows No child processes */ #define EAGAIN 11 /* Try again */ #define ENOMEM 12 /* Out of memory */ #define EACCES 13 /* Permission denied */ #define EFAULT 14 /* Bad address */ #define ENOTBLK 15 /* Block device required
Errno 0
*/ #define EBUSY 16 /* Device or resource busy */ #define EEXIST 17 /* File exists */ #define EXDEV 18 /* Cross-device link */ #define ENODEV 19 /* No such device */ #define ENOTDIR 20 /* Not a directory */ #define EISDIR 21 /* Is a directory */ #define EINVAL 22 /* Invalid argument */ #define ENFILE 23 /* File table overflow */ #define EMFILE 24 /* Too many open files */ #define ENOTTY 25 /* Not a typewriter */ #define ETXTBSY posix error codes 26 /* Text file busy */ #define EFBIG 27 /* File too large */ #define ENOSPC 28 /* No space left on device */ #define ESPIPE 29 /* Illegal seek */ #define EROFS 30 /* Read-only file system */ #define EMLINK 31 /* Too many links */ #define EPIPE 32 /* Broken pipe */ #define EDOM 33 /* Math argument out of domain of func */ #define ERANGE 34 /* Math result not representable */ #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ #define ENOSYS 38 /* Function not implemented */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Ex
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow
How To Use Errno
the company Business Learn more about hiring developers or posting ads with us Stack
Ebadf
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of errno c++ 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Getting error code when creating a socket in Linux up vote 0 down vote favorite I'm doing http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html some socket programming in Linux and am wondering how to get the error code when the function socket(...); fails. for example for the "getaddrinfo" function i can do this: //Resolve the server address and port result = (struct addrinfo *) calloc(1, sizeof(struct addrinfo)); iResult = getaddrinfo("google.com", DEFAULT_PORT, &hints, &result); if (iResult != 0){ printf("%d\n", iResult); fprintf(stderr, "getaddrinfo failed: %s\n", gai_strerror(iResult)); getchar(); exit(EXIT_FAILURE); } However I want to do a similar thing using http://stackoverflow.com/questions/27096985/getting-error-code-when-creating-a-socket-in-linux socket(...) function. According to this: http://linux.die.net/man/2/socket the function returns -1 on failure, and sets errno to the appropriate error number. How do i access this "errno" though? This is my code so far: int connectSocket = 0; connectSocket = socket(AF_INET, SOCK_STREAM, 0); printf("%d\n", connectSocket); if (connectSocket == -1){ printf("socket failed with error: %s\n", error_string); //TODO: HELP DECLARING error_string getchar(); exit(EXIT_FAILURE); } Please help. Thanks! yahya c linux sockets share|improve this question asked Nov 24 '14 at 2:23 Yahya Uddin 2,04611440 2 See errno(3) and strerror(3) manual pages. –Nikolai N Fetissov Nov 24 '14 at 2:28 2 DO NOT allocate memory for the addrinfo that you pass in the last parameter of getaddrinfo(). It will allocate the addrinfo for you, which you pass to freeaddrinfo() to free it: result = NULL; iResult = getaddrinfo(..., &result); if (iResult == 0) { ...; freeaddrinfo(result); } –Remy Lebeau Nov 24 '14 at 6:29 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted errno is a thread-local global variable, defined in
DESCRIPTION top The
Studio 2015 products Visual Studio Team Services Visual Studio Code Visual Studio Dev Essentials Office Office Word/Excel/PowerPoint Microsoft Graph Outlook OneDrive/Sharepoint Skype Services Store Cortana Bing Application Insights Languages & platforms Xamarin ASP.NET C++ TypeScript .NET - VB, C#, F# Server Windows Server SQL Server BizTalk Server SharePoint Dynamics Programs & communities Students Startups Forums MSDN Subscriber downloads Sign in Search Microsoft Search Windows Dev Center Windows Dev Center Explore Why Windows What’s new for Windows 10 Intro to Universal Windows Platform Dev Center Benefits Develop for accessibility Build for enterprise Docs Windows apps Get started Design and UI Develop API reference Publish Monetize Promote Games Get started UI design Develop Publish Desktop Get started Design Develop API reference Test and deploy Compatibility Windows IoT Microsoft Edge Windows Holographic Downloads Samples Support Dashboard Explore Why Windows What’s new for Windows 10 Intro to Universal Windows Platform Dev Center Benefits Develop for accessibility Build for enterprise Docs Windows apps Get started Design and UI Develop API reference Publish Monetize Promote Games Get started UI design Develop Publish Desktop Get started Design Develop API reference Test and deploy Compatibility Windows IoT Microsoft Edge Windows Holographic Downloads Samples Support Dashboard Networking and Internet Windows Sockets 2 Winsock Reference Winsock Reference Windows Sockets Error Codes Windows Sockets Error Codes Windows Sockets Error Codes Socket Options Winsock IOCTLs Winsock Annexes Winsock Enumerations Winsock Functions Winsock Structures and Typedefs Winsock Tracing Events Winsock SPI Windows Sockets Error Codes TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Windows Sockets Error Codes Most Windows Sockets 2 functions do not return the specific cause of an error when the function returns. For information, see the Handling Winsock Errors topic. The WSAGetLastError function returns the last error that occurred for the calling thread. When a particular Windows