summaryrefslogtreecommitdiff
path: root/Libraries/LibCore
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r--Libraries/LibCore/CTCPServer.cpp12
-rw-r--r--Libraries/LibCore/CTCPServer.h4
2 files changed, 8 insertions, 8 deletions
diff --git a/Libraries/LibCore/CTCPServer.cpp b/Libraries/LibCore/CTCPServer.cpp
index 190eacf6bd..3b5420bc5d 100644
--- a/Libraries/LibCore/CTCPServer.cpp
+++ b/Libraries/LibCore/CTCPServer.cpp
@@ -1,8 +1,8 @@
#include <AK/IPv4Address.h>
#include <AK/Types.h>
+#include <LibCore/CNotifier.h>
#include <LibCore/CTCPServer.h>
#include <LibCore/CTCPSocket.h>
-#include <LibCore/CNotifier.h>
#include <stdio.h>
#include <sys/socket.h>
@@ -54,7 +54,7 @@ RefPtr<CTCPSocket> CTCPServer::accept()
return CTCPSocket::construct(accepted_fd);
}
-IPv4Address CTCPServer::local_address() const
+Optional<IPv4Address> CTCPServer::local_address() const
{
if (m_fd == -1)
return {};
@@ -62,20 +62,20 @@ IPv4Address CTCPServer::local_address() const
sockaddr_in address;
socklen_t len = sizeof(address);
if (getsockname(m_fd, (sockaddr*)&address, &len) != 0)
- return 0;
+ return {};
return IPv4Address(address.sin_addr.s_addr);
}
-u16 CTCPServer::local_port() const
+Optional<u16> CTCPServer::local_port() const
{
if (m_fd == -1)
- return 0;
+ return {};
sockaddr_in address;
socklen_t len = sizeof(address);
if (getsockname(m_fd, (sockaddr*)&address, &len) != 0)
- return 0;
+ return {};
return ntohs(address.sin_port);
}
diff --git a/Libraries/LibCore/CTCPServer.h b/Libraries/LibCore/CTCPServer.h
index dcf6c54363..0539b3734f 100644
--- a/Libraries/LibCore/CTCPServer.h
+++ b/Libraries/LibCore/CTCPServer.h
@@ -16,8 +16,8 @@ public:
RefPtr<CTCPSocket> accept();
- IPv4Address local_address() const;
- u16 local_port() const;
+ Optional<IPv4Address> local_address() const;
+ Optional<u16> local_port() const;
Function<void()> on_ready_to_accept;