I use TCP function “recv” to receive data. Then use GetLastError() to display the error id. It is 115. In windows error.h it is #define ERROR_PROTECTION_VIOLATION 115 /* Bad user virtual address */. Could you give me any advice?
PS: this program is running under the linux.But I think the error code in linux && windows must be the same as TCP error.
I use TCP function recv to receive data. Then use GetLastError() to display the
Share
Error codes are certainly operating system specific (so your belief that it should be the same on Windows and Linux is wrong). On Linux, you should read the errno(3) man page (which you can obtain with the
man 3 errnocommand after installingmanpagesandmanpages-devpackages).TCP don’t define error codes, AFAIK. It defines a protocol.
A portable way to use
errnois to use symbolic names likeEPERMand to report the error to the user withstrerror(errno)orperror. See strerror(3) and perror(3). The actual error numbers are system specific (i.e. probably not the same on Linux/x86 and on FreeBSD/ia64). the Posix standard specifies symbolic errno.h names.I recommend you to read good books like Advanced Linux Programming and Advanced Unix Programming.
If you want to make portable code for Linux, Windows, MacOSX you could use frameworks like Qt
On my Debian/Linux/AMD64 system I have
in header
/usr/include/asm-generic/errno.hWhen using a syscall such as recv(2), read its man page to understand when a particular error can occur in it.
NB:
GetLastErroris not a standard Linux function. It is specific to your program, or to some library linked to it.