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

org.silvertunnel_ng.netlib.layer.echo.EchoNetSocket Maven / Gradle / Ivy

Go to download

SilverTunnel-NG Netlib is a free library for the Java programming language that implements and encapsulates all the complex network protocol stuff needed for anonymous communication over the Tor anonymity network. Netlib can be easily integrated in almost every existing and new Java application. The library requires Java 1.6/Java SE 6 or a newer version. The original silvertunnel Netlib can be found here : silvertunnel.org

There is a newer version: 0.0.5
Show newest version
/*
 * silvertunnel.org Netlib - Java library to easily access anonymity networks
 * Copyright (c) 2009-2012 silvertunnel.org
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, see .
 */

package org.silvertunnel_ng.netlib.layer.echo;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

import org.silvertunnel_ng.netlib.api.NetSocket;

/**
 * Echo output to input.
 * 
 * Used for educational purposes to demonstrate the NetSocket/NetLayer concept.
 * 
 * @author hapke
 */
public class EchoNetSocket implements NetSocket
{
	final PipedInputStream in;
	final PipedOutputStream out;

	public EchoNetSocket() throws IOException
	{
		in = new PipedInputStream();
		out = new PipedOutputStream(in);
	}

	@Override
	public void close() throws IOException
	{
		in.close();
		out.close();
	}

	@Override
	public InputStream getInputStream() throws IOException
	{
		return in;
	}

	@Override
	public OutputStream getOutputStream() throws IOException
	{
		return out;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy