Abstract: This page describes the Java interfaces NetLayer, NetAddress, NetSocket and NetServerSocket of the silvertunnel.org Netlib API.
The NetLayer is the general interface to all network and transport layer implementations provided by silvertunnel-ng.org [Netlib]. The common feature of all implementations of NetLayer is to support a bidirectional byte stream. In standard Java the class java.net.Socket provides access to the most relevant network+transport layer combination (TCP/IP). The NetLayer and its related interfaces want to be a more flexible replacement of standard Java sockets.
Hint: Here we are not talking about higher layer protocols as for instance as HTTP/HTTPS (see Netlib HTTP for details).
interface org.silvertunnel.netlib.api.NetLayer definition:
public interface NetLayer {
/
* Create a client connection.
* Similar to SocketFactory.createSocket()
* @param localProperties e.g. property "timeoutInMs"; can also be used to handle a "security profile"; is optional and can be null
* @param localAddress is optional and can be null
* @param remoteAdress usually one NetAddress, but can be null for layers without address
* @return a new NetSocket, not null
*
* @thrown UnsupportedOperationException if not available or not allowed for this NetLayer instance
* @throws IOException in the case of any other error
/
NetSocket createNetSocket(Map<String,Object> localProperties, NetAddress localAddress, NetAddress remoteAddress) throws IOException;<span class="cm">/** * Create a server connection (e.g. a hidden service endpoint). * Methods similar to ServerSocketFactory.createServerSocket(). * * @param localProperties e.g. property "backlog"; can also be used to handle a "security profile"; is optional and can be null * @param localListenAddress usually one NetAddress, but can be null for layers without address * @return a new NetServerSocket, not null * * @thrown UnsupportedOperationException if not available or not allowed for this NetLayer instance * @throws IOException in the case of any other error */</span> NetServerSocket <span class="nf">createNetServerSocket</span><span class="o">(</span>Map<span class="o"><</span>String<span class="o">,</span>Object<span class="o">></span> properties<span class="o">,</span> NetAddress localListenAddress<span class="o">)</span> <span class="kd">throws</span> IOException<span class="o">;</span> <span class="cm">/** * @return retrieve the status of the NetLayer - can be used to display it to the user in a proper way */</span> NetLayerStatus <span class="nf">getStatus</span><span class="o">();</span> <span class="cm">/** * Wait (block the current thread) until this NetLayer instance is up and ready, * i.e. wait until this NetLayer is in status NetLayerStatus.READY. */</span> <span class="kt">void</span> <span class="nf">waitUntilReady</span><span class="o">();</span> <span class="cm">/** * Delete all history information stored in this NetLayer instance. * Depending on the implementation, this method can close open Net(Server)Sockets that * * @thrown UnsupportedOperationException if not available or not allowed for this NetLayer instance * @throws IOException in the case of any other error */</span> <span class="kt">void</span> <span class="nf">clear</span><span class="o">()</span> <span class="kd">throws</span> IOException<span class="o">;</span> <span class="cm">/** * @return the NetAddressNameService instance that belongs to this NetLayer instance. * * @thrown UnsupportedOperationException if not available or not allowed for this NetLayer instance * @throws IOException in the case of any other error */</span> NetAddressNameService <span class="nf">getNetAddressNameService</span><span class="o">();</span>
interface NetAddressNameService is decribed on an extra page: Netlib NetAddressNameService
interface org.silvertunnel.netlib.api.NetAddress definition:
public interface NetAddress {
// yes, it is empty and very generic }
most important implementations are:
interface org.silvertunnel.netlib.api.NetSocket definition:
public interface NetSocket {
InputStream getInputStream() throws IOException;
OutputStream getOutputStream() throws IOException;
void close() throws IOException;
}
interface org.silvertunnel.netlib.api.NetServerSocket definition:
public interface NetServerSocket {
NetSocket accept() throws IOException;
void close() throws IOException;
}
Attention: currently, most NetLayer implementation only support the client-side NetSockets.
Top: [Netlib], Next: [Netlib NetLayer Implementations]
Wiki: Netlib Adapters
Wiki: Netlib Best Practices
Wiki: Netlib Direct API Usage
Wiki: Netlib HTTP
Wiki: Netlib HttpUtil
Wiki: Netlib NetLayer Implementations
Wiki: Netlib NetLayer
Wiki: Netlib Proxy
Wiki: Netlib Socket Adapter
Wiki: Netlib TorNetLayer
Wiki: Netlib URL Adapter
Wiki: Netlib