Переглянути джерело

Kernel: Let's say that listening+bound sockets "can read."

This will make it easy-peasy to select() on a socket file descriptor to wait
for incoming connections together with other activities.
Andreas Kling 6 роки тому
батько
коміт
00319c248c
1 змінених файлів з 3 додано та 0 видалено
  1. 3 0
      Kernel/LocalSocket.cpp

+ 3 - 0
Kernel/LocalSocket.cpp

@@ -97,6 +97,9 @@ RetainPtr<Socket> LocalSocket::connect(const sockaddr* address, socklen_t addres
 
 
 bool LocalSocket::can_read(SocketRole role) const
 bool LocalSocket::can_read(SocketRole role) const
 {
 {
+    if (m_bound && is_listening())
+        return can_accept();
+
     if (role == SocketRole::Accepted)
     if (role == SocketRole::Accepted)
         return !m_for_server.is_empty();
         return !m_for_server.is_empty();
     else
     else