summaryrefslogtreecommitdiff
path: root/Libraries/LibCore/UDPServer.cpp
diff options
context:
space:
mode:
authorMarcin Gasperowicz <xnooga@gmail.com>2020-05-23 15:31:30 +0200
committerGitHub <noreply@github.com>2020-05-23 15:31:30 +0200
commitc21dc21f36798e2e941e5f2f0da7531c1a228bea (patch)
tree7f3cec790db433f2749a4e5dd783995cb3f018df /Libraries/LibCore/UDPServer.cpp
parentdd924b730a7cd0bc1d5997f87e12a1df847f5961 (diff)
downloadserenity-c21dc21f36798e2e941e5f2f0da7531c1a228bea.zip
Build: Make Lagom build under macOS (#2341)
Lagom now builds under macOS. Only two minor adjustments were required: * LibCore TCP/UDP code can't use `SOCK_{NONBLOCK,CLOEXEC}` on macOS, use ioctl() and fcntl() instead * LibJS `Heap` code pthread usage ported to MacOS
Diffstat (limited to 'Libraries/LibCore/UDPServer.cpp')
-rw-r--r--Libraries/LibCore/UDPServer.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/Libraries/LibCore/UDPServer.cpp b/Libraries/LibCore/UDPServer.cpp
index ede8ff15fa..462ce5f983 100644
--- a/Libraries/LibCore/UDPServer.cpp
+++ b/Libraries/LibCore/UDPServer.cpp
@@ -31,12 +31,23 @@
#include <LibCore/UDPSocket.h>
#include <stdio.h>
+#ifndef SOCK_NONBLOCK
+# include <sys/ioctl.h>
+#endif
+
namespace Core {
UDPServer::UDPServer(Object* parent)
: Object(parent)
{
+#ifdef SOCK_NONBLOCK
m_fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
+#else
+ m_fd = socket(AF_INET, SOCK_DGRAM, 0);
+ int option = 1;
+ ioctl(m_fd, FIONBIO, &option);
+ fcntl(m_fd, F_SETFD, FD_CLOEXEC);
+#endif
ASSERT(m_fd >= 0);
}