/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include namespace IPC { template class ServerConnection : public IPC::Connection , public ClientEndpoint::Stub , public ServerEndpoint::template Proxy { public: using ClientStub = typename ClientEndpoint::Stub; using IPCProxy = typename ServerEndpoint::template Proxy; ServerConnection(ClientStub& local_endpoint, const StringView& address) : Connection(local_endpoint, Core::LocalSocket::construct()) , ServerEndpoint::template Proxy(*this, {}) { // We want to rate-limit our clients this->socket().set_blocking(true); if (!this->socket().connect(Core::SocketAddress::local(address))) { perror("connect"); VERIFY_NOT_REACHED(); } VERIFY(this->socket().is_connected()); } virtual void die() override { // Override this function if you don't want your app to exit if it loses the connection. exit(0); } }; }