libreoffice-online/loolwsd/SocketTransportTest.cpp
Tor Lillqvist 1b0230e4df Intermediate commit of start on transporting sockets to child process
Will be needed if we want loolwsd to run on Windows. Then we will have one
process receiving the connections from WebSocket clients and sending the
accepted connection sockets to child processes thatr might be already running,
either because they have been "pre-forked", or because of a collaboration
scenario where new clients join a session working on a document.

But initially we will write this as if for Unix only, so development of this
migratory socket stuff is paused for now. (And it isn't even clear whether the
API design so far is a good idea and elegantly implementable.)
2015-03-16 12:30:56 +02:00

60 lines
1.6 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <iostream>
#include <Poco/Process.h>
#include <Poco/Util/Option.h>
#include <Poco/Util/OptionSet.h>
#include <Poco/Util/ServerApplication.h>
#include "MigratorySocket.hpp"
#include "MigratorySocketTransport.hpp"
using Poco::Process;
using Poco::ProcessHandle;
using Poco::Util::Application;
using Poco::Util::Option;
using Poco::Util::OptionSet;
class SocketTransportTest: public Poco::Util::ServerApplication
{
void defineOptions(OptionSet& options) override
{
ServerApplication::defineOptions(options);
options.addOption(
Option("child", "", "when invoking the child from the parent")
.required(false)
.repeatable(false));
}
int main(const std::vector<std::string>& args) override
{
MigratorySocketTransport transport(MigratorySocketTransport::create());
Process::Args kidArgs;
kidArgs.push_back("--child");
kidArgs.push_back(transport.string());
ProcessHandle kid = Process::launch("./sockettransporttest", kidArgs);
Poco::Net::Socket socket;
MigratorySocket migrant(socket);
transport.send(migrant);
migrant.close();
return Application::EXIT_OK;
}
};
POCO_SERVER_MAIN(SocketTransportTest)
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */