根据 MSDN(VS2012 版本),sockaddr_in
定义在winsock2.h
. 没有任何例外(类似于我们在 Windows Phone 和一些 API 调用中看到的情况)。然而,当我尝试编译一个使用sockaddr_in
和包含的文件时winsock2.h
,我得到一个编译错误(如下)。
请注意,我没有收到winsock2.h not found
错误(或类似错误)。另请注意,相同的代码可以在 Windows Phone 8 上编译。
WinRT 需要包含哪些内容?
cl /Fotmp32dll\bss_conn.obj -Iinc32 -Itmp32dll -DOPENSSL_THREADS -W3 -
Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WINRT -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_
CRT_SECURE_NO_DEPRECATE -I\usr\local\ssl\fips-2.0/include /nologo /D NDEBUG /D _
USRDLL /D _WINDLL /D WINAPI_FAMILY=WINAPI_PARTITION_APP /FI SDKDDKVer.h /FI wina
pifamily.h -DOPENSSL_NO_RC5 -DOPENSSL_NO_MD2 -DOPENSSL_NO_KRB5 -DOPENSSL_NO_ENGI
NE -DOPENSSL_NO_HW -DOPENSSL_FIPS -DOPENSSL_NO_JPAKE -DOPENSSL_NO_STATIC_ENGINE
/Zi /Fdtmp32dll/lib -DOPENSSL_BUILD_SHLIBCRYPTO -c .\crypto\bio\bss_conn.c
bss_conn.c
.\crypto\bio\bss_conn.c(95) : error C2079: 'them' uses undefined struct 'sockadd
r_in'
.\crypto\bio\bss_conn.c(207) : error C2224: left of '.sin_family' must have stru
ct/union type
.\crypto\bio\bss_conn.c(207) : error C2065: 'AF_INET' : undeclared identifier
.\crypto\bio\bss_conn.c(208) : error C2224: left of '.sin_port' must have struct
/union type
.\crypto\bio\bss_conn.c(208) : warning C4013: 'htons' undefined; assuming extern
returning int
.\crypto\bio\bss_conn.c(214) : error C2224: left of '.sin_addr' must have struct
/union type
.\crypto\bio\bss_conn.c(214) : warning C4013: 'htonl' undefined; assuming extern
returning int
.\crypto\bio\bss_conn.c(217) : warning C4013: 'socket' undefined; assuming exter
n returning int
.\crypto\bio\bss_conn.c(217) : error C2065: 'AF_INET' : undeclared identifier
.\crypto\bio\bss_conn.c(217) : error C2065: 'SOCK_STREAM' : undeclared identifie
r
.\crypto\bio\bss_conn.c(217) : error C2065: 'IPPROTO_TCP' : undeclared identifie
r
.\crypto\bio\bss_conn.c(218) : error C2065: 'INVALID_SOCKET' : undeclared identi
fier
.\crypto\bio\bss_conn.c(220) : warning C4013: 'WSAGetLastError' undefined; assum
ing extern returning int
.\crypto\bio\bss_conn.c(260) : warning C4013: 'connect' undefined; assuming exte
rn returning int
.\crypto\bio\bss_conn.c(366) : error C2065: 'INVALID_SOCKET' : undeclared identi
fier
.\crypto\bio\bss_conn.c(379) : error C2065: 'INVALID_SOCKET' : undeclared identi
fier
.\crypto\bio\bss_conn.c(383) : warning C4013: 'shutdown' undefined; assuming ext
ern returning int
.\crypto\bio\bss_conn.c(384) : warning C4013: 'closesocket' undefined; assuming
extern returning int
.\crypto\bio\bss_conn.c(385) : error C2065: 'INVALID_SOCKET' : undeclared identi
fier
.\crypto\bio\bss_conn.c(422) : warning C4013: 'WSASetLastError' undefined; assum
ing extern returning int
.\crypto\bio\bss_conn.c(423) : warning C4013: 'recv' undefined; assuming extern
returning int
.\crypto\bio\bss_conn.c(447) : warning C4013: 'send' undefined; assuming extern
returning int
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
\VC\bin\x86_ARM\cl.EXE"' : return code '0x2'
Stop.