Windows networking: are SOCKET’s and file descriptors the same thing, such that file descriptor API can be used for sockets?

I’m compiling some old base network class code that’s always worked fine on both Linux and Windows 32-bit with older compilers, specifically Visual Studio 6.0 on Windows 95 up to 2016 or something on Windows 7. It’s had some conditional compilation to work on VMS, Solaris, Linux, and Windows (e.g., calling WSAStartup(), different headers, errno vs. WSALastError(), but it compiled without error (and without turning off all warnings) and ran fine.

Now re-compiling it for 64-bit required some changes and it passes g++ on Fedora 40 without warnings, but Visual Studio 2022 on Windows 11 is throwing up a huge amount of warnings that socket() and accept() return SOCKET not int.

My code has always worked fine in past decades on Windows using read() and close() for the return values of socket() and accept() but now I’m seeing at https://learn.microsoft.com/en-us/windows/win32/winsock/winsock-functions that only recv() and closesocket() are documented.

The possibilities I can see are:

  1. maybe SOCKET and a normal file descriptor are the same thing and interoperate perfectly and it’s just unfortunate that socket() and accept() return different types, but simply casting SOCKET to int is necessary and sufficient for say close() to be used instead of closesocket()? And if so, where does the documentation say that?

  2. Were they perhaps the same in the past but starting with Windows 10 or with 64-bit they’re not? And if so when?

  3. Does Windows present both API’s and I used to be getting API A and now get API B be default? So, I need to just define something before includes to get definitions where these functions return int not SOCKET? And if so what?

  4. Were they never the same and it was a total fluke this code ever worked? And if so how?

  5. Am I simply misremembering that this code worked? For instance, if it’s impossible for the code as written to have worked, maybe the applications with this code 15 or 20 years ago always used exit() and never actually called close(), or perhaps were logging that close() wasn’t working but no-one ever noticed since the app was running perfectly during the business day and only logging a warning or screwing things up at the point it was being shut down anyway? (I’m still nearly positive that it read SOCKET‘s with read() but maybe there was a subclass that overrode that default functionality?)

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật