C语言(socket)close()函数(关闭文件描述符,使其不再引用任何文件并且可以重用)(注意close(fd)后fd仍然为原值,需要手动置为-1)疑问:如果close()后引用计数不为1是否能用

1.4 关闭文件 1.4 关闭文件 1.4.1 close介绍 close用于关闭文件描述符。 而文件描述符可以是普通文件,也可以是设备,还可以是socket。在关闭时,VFS会根据不同的文件类型,执行不同的操作。 下面将通过跟踪close的内核源码来了解内核如何针对不同的文件类型执行不同的操作。 文件结构体代表一个打开的文件,系统中的每个打开的文件在内核空间都有一个关联的struct file。它由内核在打开文件时创建,并传递给在文件上进行操作的任何函数。在文件的所有实例都关闭后,内核释放这个数据结构。 SYS 阅读详情
AI摘要

本文深入探讨C语言中的close()函数,解析其工作原理及如何正确管理文件描述符,避免资源泄露。

在这里插入图片描述

man 2 close

CLOSE(2)                                                             Linux Programmer's Manual                                                            CLOSE(2)

NAME
       close - close a file descriptor

SYNOPSIS
       #include <unistd.h>

       int close(int fd);

DESCRIPTION
       close() closes a file descriptor, so that it no longer refers to any file and may be reused.  Any record locks (see fcntl(2)) held on the file it was asso‐
       ciated with, and owned by the process, are removed (regardless of the file descriptor that was used to obtain the lock).
       //close() 关闭文件描述符,使其不再引用任何文件并且可以重用。 
       //任何记录锁(参见 fcntl(2))在与它相关联并由进程拥有的文件上,都将被删除(无论用于获取锁的文件描述符是什么)。

       If fd is the last file descriptor referring to the underlying open file description (see open(2)), the resources associated with the open file  description
       are freed; if the descriptor was the last reference to a file which has been removed using unlink(2), the file is deleted.
       //如果 fd 是引用底层打开文件描述的最后一个文件描述符(参见 open(2)),则释放与打开文件描述相关的资源; 
       //如果描述符是对已使用 unlink(2) 删除的文件的最后引用,则删除该文件。

RETURN VALUE
       close() returns zero on success.  On error, -1 is returned, and errno is set appropriately.
       //close() 成功时返回零。 
       //出错时,返回 -1,并适当设置 errno。

ERRORS
       EBADF  fd isn't a valid open file descriptor.	//fd 不是有效的打开文件描述符。

       EINTR  The close() call was interrupted by a signal; see signal(7).	//close() 调用被信号中断; 见信号(7)。

       EIO    An I/O error occurred.	//发生 I/O 错误。

CONFORMING TO
       POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.

NOTES
       Not  checking  the return value of close() is a common but nevertheless serious programming error.  It is quite possible that errors on a previous write(2)
       operation are first reported at the final close().  Not checking the return value when closing the file may lead to silent loss of data.   This  can  espe‐
       cially  be  observed  with  NFS  and with disk quota.  Note that the return value should be used only for diagnostics.  In particular close() should not be
       retried after an EINTR since this may cause a reused descriptor from another thread to be closed.
       //不检查 close() 的返回值是一个常见但严重的编程错误。 
       //上一次 write(2) 操作的错误很有可能在最后的 close() 中首先报告。 
       //关闭文件时不检查返回值可能会导致数据无声丢失。 
       //这在 NFS 和磁盘配额中尤其明显。 
       //请注意,返回值应仅用于诊断。 
       //特别是 close() 不应该在 EINTR 之后重试,因为这可能会导致来自另一个线程的重用描述符被关闭。

       A successful close does not guarantee that the data has been successfully saved to disk, as the kernel defers writes.  It is not common for a filesystem to
       flush  the  buffers when the stream is closed.  If you need to be sure that the data is physically stored, use fsync(2).  (It will depend on the disk hard‐
       ware at this point.)
       //成功关闭并不保证数据已成功保存到磁盘,因为内核会延迟写入。
       //文件系统在流关闭时刷新缓冲区并不常见。
       //如果需要确保数据是物理存储的,请使用fsync(2)。(此时将取决于磁盘硬盘。)

       It is probably unwise to close file descriptors while they may be in use by system calls in other threads in the same process.  Since a file descriptor may
       be reused, there are some obscure race conditions that may cause unintended side effects.
       //当同一进程中的其他线程中的系统调用可能正在使用文件描述符时,关闭文件描述符可能是不明智的。 
       //由于可以重用文件描述符,因此存在一些可能导致意外副作用的模糊竞争条件。

SEE ALSO
       fcntl(2), fsync(2), open(2), shutdown(2), unlink(2), fclose(3)

COLOPHON
       This  page  is part of release 4.04 of the Linux man-pages project.  A description of the project, information about reporting bugs, and the latest version
       of this page, can be found at http://www.kernel.org/doc/man-pages/.

Linux                                                                       2015-08-08                                                                    CLOSE(2)

man 3 close

CLOSE(3POSIX)                                                        POSIX Programmer's Manual                                                       CLOSE(3POSIX)

PROLOG
       This  manual  page is part of the POSIX Programmer's Manual.  The Linux implementation of this interface may differ (consult the corresponding Linux manual
       page for details of Linux behavior), or the interface may not be implemented on Linux.

NAME
       close — close a file descriptor

SYNOPSIS
       #include <unistd.h>

       int close(int fildes);

DESCRIPTION
       The close() function shall deallocate the file descriptor indicated by fildes.  To deallocate means to make the file descriptor  available  for  return  by
       subsequent calls to open() or other functions that allocate file descriptors. All outstanding record locks owned by the process on the file associated with
       the file descriptor shall be removed (that is, unlocked).

       If close() is interrupted by a signal that is to be caught, it shall return −1 with errno set to [EINTR] and the state of fildes is unspecified. If an  I/O
       error  occurred  while  reading from or writing to the file system during close(), it may return −1 with errno set to [EIO]; if this error is returned, the
       state of fildes is unspecified.

       When all file descriptors associated with a pipe or FIFO special file are closed, any data remaining in the pipe or FIFO shall be discarded.

       When all file descriptors associated with an open file description have been closed, the open file description shall be freed.

       If the link count of the file is 0, when all file descriptors associated with the file are closed, the space occupied by the file shall be  freed  and  the
       file shall no longer be accessible.

       If  a  STREAMS-based fildes is closed and the calling process was previously registered to receive a SIGPOLL signal for events associated with that STREAM,
       the calling process shall be unregistered for events associated with the STREAM. The last close() for a STREAM  shall  cause  the  STREAM  associated  with
       fildes  to  be dismantled. If O_NONBLOCK is not set and there have been no signals posted for the STREAM, and if there is data on the module's write queue,
       close() shall wait for an unspecified time (for each module and driver) for any output to drain before dismantling  the  STREAM.  The  time  delay  can  be
       changed via an I_SETCLTIME ioctl() request. If the O_NONBLOCK flag is set, or if there are any pending signals, close() shall not wait for output to drain,
       and shall dismantle the STREAM immediately.

       If the implementation supports STREAMS-based pipes, and fildes is associated with one end of a pipe, the last close() shall cause a hangup to occur on  the
       other  end  of  the  pipe.  In  addition,  if  the other end of the pipe has been named by fattach(), then the last close() shall force the named end to be
       detached by fdetach().  If the named end has no open file descriptors associated with it and gets detached, the STREAM associated with that end shall  also
       be dismantled.

       If fildes refers to the master side of a pseudo-terminal, and this is the last close, a SIGHUP signal shall be sent to the controlling process, if any, for
       which the slave side of the pseudo-terminal is the controlling terminal. It is unspecified whether closing the master side of the  pseudo-terminal  flushes
       all queued input and output.

       If fildes refers to the slave side of a STREAMS-based pseudo-terminal, a zero-length message may be sent to the master.

       When there is an outstanding cancelable asynchronous I/O operation against fildes when close() is called, that I/O operation may be canceled. An I/O opera‐
       tion that is not canceled completes as if the close() operation had not yet occurred. All operations that are not canceled shall complete as if the close()
       blocked  until  the  operations completed. The close() operation itself need not block awaiting such I/O completion. Whether any I/O operation is canceled,
       and which I/O operation may be canceled upon close(), is implementation-defined.

       If a memory mapped file or a shared memory object remains referenced at the last close (that is, a process has it mapped), then the entire contents of  the
       memory  object shall persist until the memory object becomes unreferenced.  If this is the last close of a memory mapped file or a shared memory object and
       the close results in the memory object becoming unreferenced, and the memory object has been unlinked, then the memory object shall be removed.

       If fildes refers to a socket, close() shall cause the socket to be destroyed. If the socket is in connection-mode, and the SO_LINGER option is set for  the
       socket  with  non-zero linger time, and the socket has untransmitted data, then close() shall block for up to the current linger interval until all data is
       transmitted.

RETURN VALUE
       Upon successful completion, 0 shall be returned; otherwise, −1 shall be returned and errno set to indicate the error.
ERRORS
       The close() function shall fail if:

       EBADF  The fildes argument is not a open file descriptor.

       EINTR  The close() function was interrupted by a signal.

       The close() function may fail if:

       EIO    An I/O error occurred while reading from or writing to the file system.

       The following sections are informative.


EXAMPLES
   Reassigning a File Descriptor
       The following example closes the file descriptor associated with standard output for the current process, re-assigns standard output to a new file descrip‐
       tor,  and  closes the original file descriptor to clean up. This example assumes that the file descriptor 0 (which is the descriptor for standard input) is
       not closed.

           #include <unistd.h>
           ...
           int pfd;
           ...
           close(1);
           dup(pfd);
           close(pfd);
           ...

       Incidentally, this is exactly what could be achieved using:

           dup2(pfd, 1);
           close(pfd);


   Closing a File Descriptor
       In the following example, close() is used to close a file descriptor after an unsuccessful attempt is made to associate that file descriptor with a stream.

           #include <stdio.h>
           #include <unistd.h>
           #include <stdlib.h>

           #define LOCKFILE "/etc/ptmp"
           ...
           int pfd;
           FILE *fpfd;
           ...
           if ((fpfd = fdopen (pfd, "w")) == NULL) {
               close(pfd);
               unlink(LOCKFILE);
               exit(1);
           }
           ...

APPLICATION USAGE
       An application that had used the stdio routine fopen() to open a file should use the corresponding fclose() routine rather than close().  Once  a  file  is
       closed, the file descriptor no longer exists, since the integer corresponding to it no longer refers to a file.

       Implementations  may use file descriptors that must be inherited into child processes for the child process to remain conforming, such as for message cata‐
       log or tracing purposes. Therefore, an application that calls close() on an arbitrary integer risks non-conforming behavior, and close() can only  portably
       be  used  on  file descriptor values that the application has obtained through explicit actions, as well as the three file descriptors corresponding to the
       standard file streams. In multi-threaded parent applications, the practice of calling close() in a loop after fork() and before an exec call  in  order  to
       avoid  a  race  condition  of  leaking an unintended file descriptor into a child process, is therefore unsafe, and the race should instead be combatted by
       opening all file descriptors with the FD_CLOEXEC bit set unless the file descriptor is intended to be inherited across exec.

RATIONALE
       The use of interruptible device close routines should be discouraged to avoid problems with the implicit closes of file descriptors  by  exec  and  exit().
       This volume of POSIX.1‐2008 only intends to permit such behavior by specifying the [EINTR] error condition.

       Note that the requirement for close() on a socket to block for up to the current linger interval is not conditional on the O_NONBLOCK setting.

       The standard developers rejected a proposal to add closefrom() to the standard. Because the standard permits implementations to use inherited file descrip‐
       tors as a means of providing a conforming environment for the child process, it is not possible to standardize an  interface  that  closes  arbitrary  file
       descriptors above a certain value while still guaranteeing a conforming environment.

FUTURE DIRECTIONS
       None.

SEE ALSO
       Section 2.6, STREAMS, exec, fattach(), fclose(), fdetach(), fopen(), ioctl(), open(), unlink()

       The Base Definitions volume of POSIX.1‐2008, <unistd.h>

COPYRIGHT
       Portions  of  this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology -- Portable
       Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of  Electrical  and  Electronics  Engi‐
       neers,  Inc and The Open Group.  (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the event of any discrepancy between this version
       and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document.  The  original  Standard  can  be
       obtained online at http://www.unix.org/online.html .

       Any  typographical  or  formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man
       page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .

IEEE/The Open Group                                                            2013                                                                  CLOSE(3POSIX)

这里还是有疑问哈,如果父线程创建了socket_fd(如值为13),fork后子进程继承了父线程的这个socket_fd,然后子进程把这个socket_fd close()了(其实是引用计数-1,实际tcp连接还没断开),那在子进程中,这个13的socket_fd它还能继续收发消息吗?不确定它是否会禁止子进程使用这个代号为13的socket_fd


20230816

关于C语言 close() 函数的深度分析

本文将详细探讨C语言中的 close() 函数。这个函数用于关闭文件描述符,释放系统资源,并允许这些资源在其他地方重用。但是,如果 close() 后引用计数不为1,我们是否仍然可以使用它?在深入探讨这个问题之前,首先了解一下 close() 函数和文件描述符的基础知识。

文件描述符简介

在Unix或类Unix系统(如Linux)中,所有输入/输出操作都通过文件描述符(File Descriptor,简称 FD)完成。文件描述符是一个非负整数,系统用它来标识特定进程正在访问的文件。

#include <stdio.h>

int main(){
    FILE *file = fopen("example.txt", "r");
    int fd = fileno(file);
    printf("The file descriptor of example.txt is: %d\n", fd);
    return 0;
}

Close()函数及其工作原理

close() 函数定义在 <unistd.h> 头文件中,它的主要目的是关闭已打开的文件描述符。在调用 close() 函数后,文件描述符不再关联任何文件,可以被重新分配。

#include <unistd.h>
#include <fcntl.h>

int main(){
    int fd = open("example.txt", O_RDONLY);
    close(fd);
    return 0;
}

值得注意的是,即使 close() 之后,文件描述符的值仍然是原值,需要手动将其设置为 -1 或其他无效值。

引用计数与Close()函数

当有多个进程共享同一个文件描述符时,内核会为该文件描述符保持一个引用计数。例如,当一个进程通过 fork() 创建子进程时,子进程会继承父进程的所有文件描述符,并且每个文件描述符的引用计数加1。

当调用 close() 函数时,文件描述符的引用计数减1。只有当引用计数变为0时,文件描述符才真正被关闭,并且与其相关的资源被释放。

#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

int main(){
    int fd[2];
    pipe(fd);

    if (fork() == 0) {
        // Child process
        close(fd[0]);
    } else {
        // Parent process
        close(fd[1]);
        wait(NULL); // Wait for child process to finish
    }

    return 0;
}

关于Close()后引用计数不为1的问题

因此,如果 close() 后引用计数不为1,说明还有其他进程在使用该文件描述符。这时,如果你尝试读写该文件描述符,可能会出现不可预测的结果。最好的做法是,当你确定所有进程都不再需要某个文件描述符时,再调用 close()。

参考资料:

ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍
ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ

ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍
ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ

ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍
ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ        ‌‍ᅟᅠ

Linux文件描述符(FD)全面指南:从内核原理到生产故障排查 文件描述符(FD)是Linux一切皆文件设计理念的核心抽象,它以整数形式充当进程与内核I/O资源之间的桥梁。FD不仅关联着打开文件表项与inode,更支撑着标准输入输出、重定向、进程间共享等底层机制。理解其分配规则、dup2复制行为以及fork后的引用计数变化,是掌握Linux编程与运维的基石。在生产环境中,FD上限不足、句柄泄漏常引发Too many open files,借助lsof、/proc目录与ulimit可快速定位瓶颈;而socket与epoll的高并发场景更离不开对FD生命周期的精细管理。本文 阅读详情

相关推荐

ESP32网络编程实战:如何正确释放socket资源避免文件描述符耗尽

本文深入探讨ESP32网络编程中socket资源泄漏问题,详细分析lwip_close导致文件描述符耗尽的原因,并提供正确的资源释放方法。通过实战案例展示如何检测和修复泄漏,分享多线程环境下的同步技巧和长连接优化策略,帮助开发者提升物联网设备的网络稳定性。

weixin_29192141的博客 398

socket的连接关闭的方式和过程

close的主要流程: 1)关闭监听句柄 先从最右边的分支说说关闭监听socket的那些事。用于listen的监听句柄也是使用close关闭,关闭这样的句柄含义当然很不同,它本身并不对应着某个TCP连接,但是,附着在它之上的却可能有半成品连接。什么意思呢?之前说过TCP是双工的,它的打开需要三次握手,三次握手也就是3个步骤,其含义为:客户端打开接收、发送的功能;服务器端认可并也打开接收、发送的功能;客户端认可。当第1、2步骤完成、第3步步骤未完成时,就会在服务器上有许多半连接,close这个操作主要是清理

NeverGx的博客 9136

close函数概念和使用案例

close函数是socket编程中释放资源的核心系统调用,用于终止连接并释放内核资源。文章详细解析了其原型、参数、返回值及常见错误,重点阐述了其在TCP/UDP协议中的不同行为:TCP会触发四次挥手确保数据完整,而UDP直接释放资源。同时对比了close与shutdown的关键区别,包括资源释放机制和方向控制能力。最后提供了客户端/服务器使用场景和四项重要注意事项,如避免重复关闭、处理TIME_WAIT状态等,强调合理使用对构建健壮网络程序的重要性。

weixin_42108533的博客 1758

close函数

关于最小文件描述符的理解

weixin_38011893的博客 4993

【C语言】关闭socket需要包含的头文件

通常用于网络编程,包括创建套接字、绑定、监听、接受连接等,但关闭套接字实际上是通过通用的文件描述符关闭函数。在 Linux 系统下,`close()` 函数是用来关闭一个文件描述符的系统调用。通常,这个系统调用是在。linux系统,包含了头文件,因此,为了避免编译器警告,需要包含。头文件中声明的,而不是在。后,编译器不再发出关于。函数的隐式声明的警告。

数字人生 1831

电路抗干扰原理及应用(1)

电路抗干扰原理——介绍干扰源、干扰途径、抗干扰技术(接地技术)

qq_34758408的博客 2059

网络编程---socket中关闭套接字的函数close和shutdown区别

1.函数close():释放描述符 某个进程调用了close(sockfd)函数,描述符的计数就会减1,直到计数为0。当计数为0时,也就是所用进程都调用了close,这时程序会调用shutdown函数释放套接字。 2.函数shutdown():断开连接 有些地方见到调用了shutdown()之后接着就是close()。有种解释是:调用shutdown()只是进行了TCP断开, 并没有释放文件描述符,需要调用close()来释放。 某个进程中调用了shutdown(sockfd,SHUT_RDWR)函数,其

m0_46598535的博客 6075

Polyworks脚本开发学习笔记(十五)-用Python连接Polyworks的COM组件

Polyworks脚本开发学习笔记(十五)-利用Python连接Polyworks的COM组件

qq_43662503的博客 2499

linux 文件描述符 引用计数(close(fd)只是使fd的引用计数-1)

在unix和linux平台需要考虑多进程的情况,fork时,子进程继承父进程所拥有的文件描述符,需要所有拥有者都close文件描述符才会把资源销毁,所以需要使用引用计数。 参考文章:linux socket close()函数将socket描述字引用计数-1是什么意思? 后更。。。 ...

Dontla的博客 2322

2023年LitCTF web组wp

1、导弹迷踪2、1zjs3、php是世界上最好的语言!!4、Ping5、我Flag呢?7、作业管理系统8、Vim yyds10、这是什么?SQL!注一下!11、Flag点击就送!12、就当无事发生13、彩蛋。

m0_74160536的博客 1587

【高低温试验】试验报告模板

高低温循环试验,验证被测设备(DUT)在极端高温、低温环境下的性能稳定性、功能可靠性及安全性,确保其符合设计规范和相关标准(如GB/T 2423.1、GB/T 2423.2)。:验证设备在剧烈温度变化下的耐受能力(如-40℃↔+85℃,温变速率≥10℃/min)。低温测试标准:GB/T 2423.2-2008(温度-40℃,保持时间4小时):模拟高温高湿环境(如温度+60℃,湿度95%RH),测试防潮性能。

电路巫师把一切不可能变成不可能 1565

linux中fd的几点理解——一切皆文件

fd 全称是 file descriptor,文件描述符,又称句柄。当我们在打开一个文件,创建一个 socket, 创建一个 epoll 时,返回值往往都用一个变量 int fd 来表示。

weixin_38184628的博客 5593

STM32 IAP+APP合并Hex文件全自动脚本(Keil5一键生成)

本文详细介绍了一种基于Keil5开发环境的STM32 IAP与APP程序Hex文件全自动合并方案。通过编写批处理或Python脚本,并将其集成到Keil的编译后流程中,实现一键编译、自动合并,彻底解决手动操作繁琐易错的问题,极大提升STM32固件开发与远程升级的效率。

weixin_29191761的博客 305

c语言socket关闭,如何在c语言下关闭socket

c语言关闭socket的两种方式一、shutdown()#includeint shutdown(int sockfd,int how);how的方式有三种分别是SHUT_RD(0):关闭sockfd上的读功能,此选项将不允许sockfd进行读操作。不允许接受。SHUT_WR(1):关闭sockfd的写功能,此选项将不允许sockfd进行写操作。不允许发送。SHUT_RDWR(2):关闭sockf...

weixin_42359449的博客 2395

C++ 图像线特征提取(CannyLine算法+opencv3.4.6)

C++ 图像线特征提取(CannyLine算法+opencv3.4.6)

weixin_43896283的博客 1084

EMC原理-传导(共模、差模)与辐射(近场、远场)详解

本文深入介绍了电磁兼容(EMC)的基本概念,包括EMI和EMS,以及如何处理传导干扰(共模、差模)和辐射干扰(近场、远场)。详细讨论了近场感应、远场辐射的原理,滤波器和屏蔽技术在抑制噪声信号中的作用。此外,探讨了差模和共模干扰的来源、影响及滤除方法,如使用差模电感、电容和共模线圈。最后,提到了穿心电容在滤除高频噪声中的应用。

让你爱上电路设计 3549

linux检查socekt是否断开,如何在C语言中判断socket是否已经断开

如果不主动关闭socket的话,系统不会自动关闭的,除非当前进程挂掉了,操作系统把占用的socket回收了才会关闭。小编今天跟大家简单介绍下如何在C语言中判断socket是否已经断开下面来介绍判断非阻塞SOCKET是否已经断开的几种方法:注意要区分不同操作系统分别进行测试, 包括WINDOWS, LINUX和UNIX会各有不同。在WINDOWS下比较简单,可以使用FD_CLOSE事件判断SOCKE...

weixin_33488806的博客 1288

基金估值核算系统三国杀:恒生 VS 赢时胜 VS 融选!

本文对比分析了恒生电子、赢时胜和融选科技三家金融科技公司的基金估值系统。恒生电子作为行业龙头,在公募基金领域占据较大份额,其新一代估值系统6.0采用微服务架构,自动化程度高;赢时胜在中型公募和券商资管领域优势明显,其V5.5系统在信创适配和复杂产品处理方面表现突出;融选科技作为新兴厂商,提供轻量化解决方案,适合中小型机构。文章从市场格局、系统定位、技术架构、成本构成和用户反馈五个维度进行深入比较,为金融机构选型提供参考。当前估值系统市场呈现"三国鼎立"格局,各具特色,选型需结合机构规模、

magbox520的博客 825

openssl之BIO系列之12---文件描述符(fd)类型BIO

文件描述符(fd)类型BIO        ---根据openssl doc/crypto/bio_s_fd.pod翻译和自己的理解写成        (作者:DragonKing Mailwzhah@263.net 发布于:http://gdwzh.126.com之openssl专业论坛)        文件描述符类型BIO也是一个source/sink型的BIO,它定义了以下一些类型的函数(o

内网安全与OpenSSL专栏 3105

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

c语言下,关闭socket的两种方式

c语言关闭socket的两种方式 一、shutdown() #include int shutdown(int sockfd,int how); how的方式有三种分别是 SHUT_RD(0):关闭sockfd上的读功能,此选项将不允许sockfd进行读操作。不允许接受。 SHUT_WR(1):关闭sockfd的写功能,此选项将不允许sockfd进行写操作。不允

oslo---let's go 1万+

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Linux socket关闭连接shutdown与close

在Linux socket关闭连接的方法有两种分别是shutdown和close,首先看一下shutdown的定义 #include int shutdown(int sockfd,int how); how的方式有三种分别是: SHUT_RD(0):关闭sockfd上的读功能,此选项将不允许sockfd进行读操作。 SHUT_WR(1):关闭sockfd的写功能,此选项将不允许sock

hjxhjh的专栏 3966

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

linux tcp优雅关闭,socket关闭连接与close和shutdown的区别及优雅关闭socket的方法:SO_LINGER...

TCP主动关闭连接appl: close(), --> FIN FIN_WAIT_1 //主动关闭socket方,调用close关闭socket,发FIN--> ACK "TIME_WAIT" -- 2MSL timeout -->CLOSED//TIME_WAIT,防止ACK没有给到对方。注意:close时,如果TCP发送队列中还有数据,那么将会发送RST...

weixin_39662263的博客 1832

【计算机网络】网络编程接口 Socket API 解读(11)

Socket 是网络协议栈暴露给编程人员的 API,相比复杂的计算机网络协议,API 对关键操作和配置数据进行了抽象,简化了程序编程。 本文讲述的 socket 内容源自 Linux man。本文主要对各 API 进行详细介绍,从而更好的理解 socket 编程。 2.头文件 3.接口定义 4.接口描述 shutdown() 调用会将 sockfd 指定的套接字上全双工连接上的一端或者两端关闭。如果 how 指定为 SHUT_RD,那么套接字上将不允许接收;

最是书香能致远,腹有诗书气自华 2291

socket关闭之close()和shutdown()的差异

对于一个tcp连接,在c语言里一般有2种方法可以将其关闭:close(sock_fd); // 或者 shutdown(sock_fd, ...);多数情况下这2个方法的效果没有区别,可以互换使用。除了: close() 是针对file的操作 shutdown() 是针对socket的操作 unix系统里socket是一个文件,但文件不一定是一个socket;所以在进入系统调用后和达到协议层前(发出

renwotao2009的专栏 9252

socket由浅入深:从创建到实现到底层

Socket 对象 (Kernel Object)这是一个存在于操作系统内核内存中的复杂数据结构。它包含了网络连接的所有状态信息,例如:协议类型 (TCP/UDP)、连接状态 (ESTABLISHED, TIME_WAIT等)、本地/远端IP和端口、指向发送/接收缓冲区的指针、TCP协议控制块 (TCB) 等。它是网络通信的实际资源实体。它内部包含一个引用计数 (reference count),用于追踪有多少个文件描述符指向它文件描述符 (File Descriptor, fd)这是一个。

weixin_74402791的博客 1011

c语言socket约定编码类型,如何在c语言下关闭socket

如何在c语言下关闭socketc语言关闭socket的两种方式一、shutdown()#includeint shutdown(int sockfd,int how);how的方式有三种分别是SHUT_RD(0):关闭sockfd上的读功能,此选项将不允许sockfd进行读操作。不允许接受。SHUT_WR(1):关闭sockfd的写功能,此选项将不允许sockfd进行写操作。不允许发送。SHUT_...

weixin_33983620的博客 412
上一篇: 什么是posix?(Portable Operating System Interface 便携式操作系统接口)
下一篇: 海康摄像头 heop 拷贝到 workspace 脚本
Dontla
Dontla 科技专利发明人 科技专利发明人 领域专家: Python技术领域 领域专家: Python技术领域
博客等级 码龄8年 2万+粉丝 4087原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dontla

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值