All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.citahub.cita.protocol.ipc.WindowsNamedPipe Maven / Gradle / Ivy

The newest version!
package com.citahub.cita.protocol.ipc;

import java.io.IOException;
import java.io.RandomAccessFile;

/**
 * Windows named pipe IO implementation for IPC.
 */
public class WindowsNamedPipe implements IOFacade {

    private final RandomAccessFile pipe;

    public WindowsNamedPipe(String ipcSocketPath) {
        try {
            pipe = new RandomAccessFile(ipcSocketPath, "rw");
        } catch (IOException e) {
            throw new RuntimeException(
                    "Provided file pipe cannot be opened: " + ipcSocketPath, e);
        }
    }

    @Override
    public void write(String payload) throws IOException {
        pipe.write(payload.getBytes());
    }

    @Override
    public String read() throws IOException {
        return pipe.readLine();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy