I am programming an SSL socket and many times I have seen something (variable name, function...) with FD or SD in its name. For example, OpenSSL provides the function:
int fd = SSL_get_fd(...);
In many tutorials (here, here and here), this is used:
int sd = socket(...);
Can anyone explain, what does FD and SD stand for?
Thanks
A file descriptor is a non-negative integer, represented in C programming language as the type int. wfd , rfd will stand for write-FD and read-FD. sd is not a standard moniker, but it will likely stand for 'socket file descriptor', ie. a FD that corresponds to a socket.
In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.
addrlen is a pointer to a socklen_t where the length of the struct sockaddr filled in will be returned. int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen); The function connect connects a socket on this host to another host. The function returns 0 on success or −1 on failure.
int sockfd = socket(domain, type, protocol) sockfd: socket descriptor, an integer (like a file-handle) domain: integer, specifies communication domain. We use AF_ LOCAL as defined in the POSIX standard for communication between processes on the same host.
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.
wfd
, rfd
will stand for write-FD and read-FD. sd
is not a standard moniker, but it will likely stand for 'socket file descriptor', ie. a FD that corresponds to a socket. From the same SSL_get_fd
page:
fd will typically be the socket file descriptor of a network connection
"fd" is generally an abbreviation of File Descriptor. On POSIX systems like Linux, OSX and the BSD variants a file descriptor is used not only for files, but for sockets, device communication and other things as well
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With