Skip to content
  • Bin Meng's avatar
    3665fadd
    tests/qtest: libqtest: Replace the call to close a socket with closesocket() · 3665fadd
    Bin Meng authored
    
    
    close() is a *nix function. It works on any file descriptor, and
    sockets in *nix are an example of a file descriptor.
    
    closesocket() is a Windows-specific function, which works only
    specifically with sockets. Sockets on Windows do not use *nix-style
    file descriptors, and socket() returns a handle to a kernel object
    instead, so it must be closed with closesocket().
    
    In QEMU there is already a logic to handle such platform difference
    in os-posix.h and os-win32.h, that:
    
      * closesocket maps to close on POSIX
      * closesocket maps to a wrapper that calls the real closesocket()
        on Windows
    
    Replace the call to close a socket with closesocket() instead.
    
    Signed-off-by: default avatarBin Meng <bin.meng@windriver.com>
    Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
    Message-Id: <20220925113032.1949844-46-bmeng.cn@gmail.com>
    Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
    3665fadd
    tests/qtest: libqtest: Replace the call to close a socket with closesocket()
    Bin Meng authored
    
    
    close() is a *nix function. It works on any file descriptor, and
    sockets in *nix are an example of a file descriptor.
    
    closesocket() is a Windows-specific function, which works only
    specifically with sockets. Sockets on Windows do not use *nix-style
    file descriptors, and socket() returns a handle to a kernel object
    instead, so it must be closed with closesocket().
    
    In QEMU there is already a logic to handle such platform difference
    in os-posix.h and os-win32.h, that:
    
      * closesocket maps to close on POSIX
      * closesocket maps to a wrapper that calls the real closesocket()
        on Windows
    
    Replace the call to close a socket with closesocket() instead.
    
    Signed-off-by: default avatarBin Meng <bin.meng@windriver.com>
    Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
    Message-Id: <20220925113032.1949844-46-bmeng.cn@gmail.com>
    Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
Loading