Skip to content

Truly independent web browser

LibCore: Differentiate between sockets and pipes in is_socket()

Zaggy102424b1968c51b1
diff --git a/Libraries/LibCore/SystemWindows.cpp b/Libraries/LibCore/SystemWindows.cpp
index 1e000f2a847..1aefd9c90f6 100644
--- a/Libraries/LibCore/SystemWindows.cpp
+++ b/Libraries/LibCore/SystemWindows.cpp
@@ -151,8 +151,9 @@ ErrorOr<int> dup(int handle)
bool is_socket(int handle)
{
- // FILE_TYPE_PIPE is returned for sockets and pipes. We don't use Windows pipes.
- return GetFileType(to_handle(handle)) == FILE_TYPE_PIPE;
+ int type = 0;
+ int length = sizeof(type);
+ return ::getsockopt(static_cast<SOCKET>(handle), SOL_SOCKET, SO_TYPE, reinterpret_cast<char*>(&type), &length) == 0;
}
ErrorOr<void> bind(int sockfd, struct sockaddr const* name, socklen_t name_size)