在 C++ 中打印套接字时,数字代表什么?
What does the number represent when printing a socket in C++?
SOCKET sampleSocket;
cout << sampleSocket << endl;
// End up with a number
我注意到当我使用 cout 打印套接字时,我会收到一个数字——该数字代表什么以及如何在使用 cout 之外检索它?
In Winsock applications, a socket descriptor is not a file descriptor and must be used with the Winsock functions.
[...] Because the SOCKET type is unsigned, compiling existing source code from, for example, a UNIX environment may lead to compiler warnings about signed/unsigned data type mismatches.
从该文档中我们可以了解到它是一种 unsigned
数据类型。但是,确切的整数类型仍然是 implementation-defined。它可能是 32 位或 64 位 unsigned
整数。
SOCKET sampleSocket;
cout << sampleSocket << endl;
// End up with a number
我注意到当我使用 cout 打印套接字时,我会收到一个数字——该数字代表什么以及如何在使用 cout 之外检索它?
In Winsock applications, a socket descriptor is not a file descriptor and must be used with the Winsock functions. [...] Because the SOCKET type is unsigned, compiling existing source code from, for example, a UNIX environment may lead to compiler warnings about signed/unsigned data type mismatches.
从该文档中我们可以了解到它是一种 unsigned
数据类型。但是,确切的整数类型仍然是 implementation-defined。它可能是 32 位或 64 位 unsigned
整数。