socket编程,什么是FD和SD

Socket programming, what is FD and SD

我正在编写一个 SSL 套接字,我多次看到名称中带有 FD 或 SD 的东西(变量名、函数...)。例如,OpenSSL 提供了函数:

int fd = SSL_get_fd(...);

在很多教程中(here, here and here),是这样使用的:

int sd = socket(...);

谁能解释一下,FD和SD分别代表什么?

谢谢

"fd"一般是文件描述符的缩写。在 Linux、OSX 和 BSD 变体等 POSIX 系统上,文件描述符不仅用于 文件 ,还用于套接字、设备通信和还有其他事情

SSL_get_fd:

SSL_get_fd() returns the file descriptor

File Descriptor:

In Unix and related computers operating systems, a file descriptor (FD, less frequently fildes) is an abstract indicator used to access a file or other input/output resource, such as a pipe or network connection. File descriptors are part of the POSIX application programming interface. A file descriptor is a non-negative integer, represented in C programming language as the type int.

wfdrfd分别代表write-FD和read-FD。 sd 不是标准的绰号,但它可能代表 'socket file descriptor',即。一个FD对应一个socket。来自同一 SSL_get_fd 页面:

fd will typically be the socket file descriptor of a network connection