[questions]
Vs2015 appears when writing socket client. (this is the second time I have encountered this problem. Last time vs2017, I must remember it to facilitate myself to check in the future: P)
SOCKADDR_ IN ClientAddr;
ClientAddr.sin_ family = AF_ INET;
ClientAddr.sin_ addr.S_ un.S_ addr = inet_ addr(“127.0.0.1”);
ClientAddr.sin_ Port = htons (port);
error c4996: ‘INET_ addr’: Use inet_ pton() or InetPton() instead or define _ WINSOCK_ DEPRECATED_ NO_ WARNINGS to disable deprecated API warnings
[reason]
In the version after vs2013, INET is added_ New functions such as Pton () and inetpton () are used for IP address conversion between “dotted decimal” and “binary integer”, and can handle IPv4 and IPv6. And INET_ Addr is an old function. Higher version vs uses a new function by default when compiling, so this error will be reported.
[solution 1]
Replace INET with the new function suggested_ Addr function.
[solution 2]
Modify the vs configuration and tell it I want the old function
1. Modification method: Item – & gt; attribute – & gt; C / C + + – & gt; general – & gt; SDL check, change “yes” to “no”.
2. Property page of file_ CRT_ SECURE_ NO_ “Warnings” plus
– – –
copyright notice: This is CSDN blogger Rani_ The original article of “ZZ” follows CC 4.0 by-sa copyright agreement. Please attach the link of original source and this statement.
Link to the original text: https://blog.csdn.net/weixin_ 42731241/article/details/96143934
Read More:
- Error: sudo required (or change ownership, or define N_PREFIX)
- ERROR: Adobe Flashplayer or HTML5 Browser with WebGL or CSS3D support requ
- 【.Net Core】using declarations‘ is not available in C# 7.3. Please use language version 8.0 or greate
- 12c Instant Client Throws System Error Code 126 or 193 or 106
- Error in installing torch vision or pilot on Linux or Jetson nano: the headers or library files could not be found for JPEG
- [Solved] Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
- Xcode: error: linker command failed with exit code 1(use -v to see invocation) or libstdc++.6.0 is missing
- error C4996: ‘scanf‘: This function or variable may be unsafe.Visual Studio Series compilers report errors using scanf function
- Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“
- Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space
- [Solved] error: Microsoft Visual C++ 14.0 or greater is required
- Error: Projects must list all files or use an ‘include‘ pattern.
- C language string processing error warning, c4996, sprintf, predicted, c4996, strcpy, c4996, strcat
- Syntax Error: Error: ENOENT: no such file or directory, scandir ‘D:
- #During OpenGL development, fatal error C1083: can’t open include file: “GL / glut. H”: no such file or directory
- The media could not be loaded, either because the server or network failed or because the format is
- [Vue warn]: Do not use built-in or reserved HTML elements as component id: article
- C language error: expected declaration or statement at end of input
- Use xx [‘xx ‘] = XX to set field value or does not support field: XXX