libreoffice-online/loolwsd/MigratorySocketTransport.hpp
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

52 lines
1.5 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/.
*/
#ifndef INCLUDED_MIGRATORYSOCKETTRANSPORT_HPP
#define INCLUDED_MIGRATORYSOCKETTRANSPORT_HPP
#include <Poco/Net/Socket.h>
#include "MigratorySocket.hpp"
class MigratorySocketTransport: public Poco::Net::Socket
{
public:
/// Create the parent process end
static MigratorySocketTransport create();
/// Create the child process end
MigratorySocketTransport(std::string string);
~MigratorySocketTransport();
/// Parent side: String to be passed to child process (for
/// instance on the command line) for use in the child process in
/// the child kind of our constructor.
std::string string();
/// Parent side: Send a socket to the child
void send(MigratorySocket socket);
/// Child side: Receive a socket sent from an ancestor process
MigratorySocket receive();
private:
/// Create the parent process end
MigratorySocketTransport(poco_socket_t sockets[2]);
bool _thisIsParent;
/// Socket used for transport. A socket pair with one end used in
/// the parent instance, one in the child.
poco_socket_t _sockets[2];
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */