Why are there WSA pendants for socket(), connect(), send() and so on, but not for closesocket()?

后端 未结 4 772
我在风中等你
我在风中等你 2021-02-05 16:08

I\'m going to try to explain what I mean using a few examples:

  • socket() -> WSASocket()
  • connect() -> WSAConnect()
  • send() -> WSASend()
  • sen
4条回答
  •  走了就别回头了
    2021-02-05 16:51

    This is written in the MSDN documentation:

    Renamed Functions

    In two cases it was necessary to rename functions that are used in Berkeley Sockets in order to avoid clashes with other Microsoft Windows API functions.

    Close and Closesocket

    Sockets are represented by standard file descriptors in Berkeley Sockets, so the close function can be used to close sockets as well as regular files. While nothing in Windows Sockets prevents an implementation from using regular file handles to identify sockets, nothing requires it either. On Windows, sockets must be closed by using the closesocket routine. ON Windows, using the close function to close a socket is incorrect and the effects of doing so are undefined by this specification.

    Ioctl and Ioctlsocket/WSAIoctl

    Various C language run-time systems use the IOCTLs for purposes unrelated to Windows Sockets. As a consequence, the ioctlsocket function and the WSAIoctl function were defined to handle socket functions that were performed by IOCTL and fcntl in the Berkeley Software Distribution.

提交回复
热议问题