public class AnonTCPChannel extends java.lang.Object implements AnonChannel
AnonService.createChannel(AnonChannel.TCP)
. Afterwards you
connect to the target host using connect
. Data
transmission can be done by using the Input-/Outputstream returned by
getInputStream()
/ getOutputStream()
.
Hint: for performance optimisation / efficiency have a look at
setSentAutoFlushDelay(int)
.
Example:
AnonService anonservice=AnonServiceFactory.getAnonServiceInstance(AnonServiceFactory.SERVICE_ANON);
AnonTCPChannel anonchannel=(AnonTCPChannel)anonservice.createChannel(AnonChannel.TCP);
anonchannel.connect("desti.nation",80);
InputStream in=anonchannel.getInputStream();
OutputStream out=anonchannel.getOutputStream();
in.read();
out.write(...);
anonchannel.close();
Note: Since the AnonTCPChannel implementation uses an anonymous SOCKS channel, an AnonTCPChannel can only be established using a cascade which supports SOCKS.
HTTP, SMTP, SOCKS, TCP, UDP, UDP_OVER_TCP, UDP_OVER_UDP, VPN
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the channel and releases all resources used.
|
void |
connect(java.lang.String hostname,
int port)
Establishes an anonymous TCP connection to the given host:port.
|
java.io.InputStream |
getInputStream()
The returned InputStream could be used to receive data.
|
int |
getOutputBlockSize()
Returns a value that indicates the current optimum size of data to write.
|
java.io.OutputStream |
getOutputStream()
The returned OutputStream could be used to send data.
|
boolean |
isClosed()
Returns if the channel is already closed, i.e. no data can be sent / recieved any more on this channel.
|
void |
setSentAutoFlushDelay(int msAutoFlushDelay)
Sets the time to wait before actually sending some data over this channel
in case the packet belonging to the underlying anonymisation protocol is
not full yet.
|
public void connect(java.lang.String hostname, int port) throws java.io.IOException
hostname
- the domain name of the target hostport
- the target port numberjava.io.IOException
- if the connection could not be establishedpublic void setSentAutoFlushDelay(int msAutoFlushDelay)
This method can be used for performance optimisations / efficiency. One
use case would be if you know that this channel will sent data
immediately after connection establishment. Therefore you would call
setSentAutoFlushDelay
with some delayvalue > 0
just before you call the connect
method. If you call
Outputstream.write
within delayvalue
milliseconds after the connect
call then the data you intend
to sent will be piggybacked on the connect request. This will save some
roundtrip-time delay.
Additionally, using this method correctly could decrease the bandwidth overhead introduced by the underlying anonymisation protocol. Many anonymisation protocols fragment the data stream into fixed sized packets which are filled with dummy data if not enough real data is available. Therefore waiting a certain amount of time for additional real data can increase the channel utilisation.
Note: This method will not do anything at the moment as the implementation is not ready yet.
msAutoFlushDelay
- the amount of time in milliseconds to wait for new data before
the current sent buffer is flushed. Setting this value to
0
will always auto flush immediately. Setting this
value to -1
will only flush the sent buffer, if the
sent buffer is full, i.e. getOutputBufgferSize many bytes are
contained in the buffer.public java.io.InputStream getInputStream()
AnonChannel
getInputStream
in interface AnonChannel
public java.io.OutputStream getOutputStream()
AnonChannel
getOutputStream
in interface AnonChannel
public int getOutputBlockSize()
AnonChannel
getOutputBlockSize
in interface AnonChannel
public void close()
AnonChannel
close
in interface AnonChannel
public boolean isClosed()
AnonChannel
isClosed
in interface AnonChannel
true
, if the channel is already closedCopyright © 2023. All rights reserved.