Package jnr.unixsocket

Examples of jnr.unixsocket.UnixSocketAddress


public class UnixServer {

    public static void main(String[] args) throws IOException {
        java.io.File path = new java.io.File("/tmp/fubar.sock");
        path.deleteOnExit();
        UnixSocketAddress address = new UnixSocketAddress(path);
        UnixServerSocketChannel channel = UnixServerSocketChannel.open();

        try {
            Selector sel = NativeSelectorProvider.getInstance().openSelector();
            channel.configureBlocking(false);
View Full Code Here


        public final boolean rxready() {
            try {
                ByteBuffer buf = ByteBuffer.allocate(1024);
                int n = channel.read(buf);
                UnixSocketAddress remote = channel.getRemoteSocketAddress();
                System.out.printf("Read in %d bytes from %s\n", n, remote);
               
                if (n > 0) {
                    buf.flip();
                    channel.write(buf);
View Full Code Here

public class UnixClient {
    public static void main(String[] args) throws IOException {
        java.io.File path = new java.io.File("/tmp/fubar.sock");
        String data = "blah blah";
        UnixSocketAddress address = new UnixSocketAddress(path);
        UnixSocketChannel channel = UnixSocketChannel.open(address);
        System.out.println("connected to " + channel.getRemoteSocketAddress());
        PrintWriter w = new PrintWriter(Channels.newOutputStream(channel));
        w.print(data);
        w.flush();
View Full Code Here

        }

        ByteList path = new ByteList(raw, 2, end, false);
        String pathStr = path.toString();

        return new UnixSocketAddress(new File(pathStr));
    }
View Full Code Here

        try {
            if(server) {
                UnixServerSocketChannel channel = UnixServerSocketChannel.open();
                UnixServerSocket socket = channel.socket();

                socket.bind(new UnixSocketAddress(new File(fpath)));

                this.channel = channel;

            } else {
                File fpathFile = new File(fpath);

                if (!fpathFile.exists()) {
                    throw runtime.newErrnoENOENTError("unix socket");
                }
               
                UnixSocketChannel channel = UnixSocketChannel.open();

                channel.connect(new UnixSocketAddress(fpathFile));

                this.channel = channel;

            }
View Full Code Here

                UnixServerSocketChannel channel = UnixServerSocketChannel.open();
                UnixServerSocket socket = channel.socket();

                // TODO: listen backlog

                socket.bind(new UnixSocketAddress(new File(fpath)));

                init_sock(runtime, channel, fpath);

            } else {
                File fpathFile = new File(fpath);

                if (!fpathFile.exists()) {
                    throw runtime.newErrnoENOENTError("unix socket");
                }
               
                UnixSocketChannel channel = UnixSocketChannel.open();

                channel.connect(new UnixSocketAddress(fpathFile));

                init_sock(runtime, channel);

            }
View Full Code Here

        }

        ByteList path = new ByteList(raw, 2, end, false);
        String pathStr = Helpers.decodeByteList(context.runtime, path);

        return new UnixSocketAddress(new File(pathStr));
    }
View Full Code Here

TOP

Related Classes of jnr.unixsocket.UnixSocketAddress

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.