forked from I2P_Developers/i2p.i2p
Streaming: Throw I2PSocketException when connection is reset,
display new error page in HTTP client (ticket #643) javadocs
This commit is contained in:
@@ -6,8 +6,11 @@ import java.net.SocketTimeoutException;
|
||||
import net.i2p.I2PException;
|
||||
|
||||
/**
|
||||
* Defines how to listen for streaming peer connections
|
||||
*
|
||||
* Streaming server socket returned by {@link I2PSocketManager#getServerSocket()}.
|
||||
* Defines how to listen for streaming peer connections.
|
||||
*<p>
|
||||
* Note that this is not a standard Java {@link java.net.ServerSocket},
|
||||
* if you need one of those, use {@link I2PSocketManager#getStandardServerSocket()} instead.
|
||||
*/
|
||||
public interface I2PServerSocket {
|
||||
/**
|
||||
|
@@ -9,9 +9,10 @@ import java.nio.channels.SelectableChannel;
|
||||
import net.i2p.data.Destination;
|
||||
|
||||
/**
|
||||
* Minimalistic adapter between the socket api and I2PTunnel's way.
|
||||
* Note that this interface is a "subinterface" of the interface
|
||||
* defined in the "official" streaming api.
|
||||
* Streaming socket returned by {@link I2PSocketManager#connect(Destination)}.
|
||||
*<p>
|
||||
* Note that this is not a standard Java {@link java.net.Socket},
|
||||
* if you need one of those, use {@link I2PSocketManager#connectToSocket(Destination)} instead.
|
||||
*/
|
||||
public interface I2PSocket extends Closeable {
|
||||
/**
|
||||
@@ -27,6 +28,12 @@ public interface I2PSocket extends Closeable {
|
||||
/**
|
||||
* As of 0.9.9 will throw an IOE if socket is closed.
|
||||
* Prior to that would return null instead of throwing IOE.
|
||||
*<p>
|
||||
* Note that operations on the returned stream may return an
|
||||
* {@link IOException} whose <i>cause</i> as returned by
|
||||
* {@link IOException#getCause()} is an {@link I2PSocketException}.
|
||||
* If so, the client may retrieve a status code via
|
||||
* {@link I2PSocketException#getStatus()} to provide specific feedback to the user.
|
||||
*
|
||||
* @return an InputStream to read from the socket. Non-null since 0.9.9.
|
||||
* @throws IOException on failure
|
||||
@@ -36,6 +43,12 @@ public interface I2PSocket extends Closeable {
|
||||
/**
|
||||
* As of 0.9.9 will throw an IOE if socket is closed.
|
||||
* Prior to that would return null instead of throwing IOE.
|
||||
*<p>
|
||||
* Note that operations on the returned stream may return an
|
||||
* {@link IOException} whose <i>cause</i> as returned by
|
||||
* {@link IOException#getCause()} is an {@link I2PSocketException}.
|
||||
* If so, the client may retrieve a status code via
|
||||
* {@link I2PSocketException#getStatus()} to provide specific feedback to the user.
|
||||
*
|
||||
* @return an OutputStream to write into the socket. Non-null since 0.9.9.
|
||||
* @throws IOException on failure
|
||||
|
@@ -20,7 +20,18 @@ public class I2PSocketException extends SocketException {
|
||||
private static final String BUNDLE_NAME = "net.i2p.client.streaming.messages";
|
||||
|
||||
/**
|
||||
* Use canned message for this status code
|
||||
* Router and I2CP status codes are 0 - 511. Start ours at 512.
|
||||
* @since 0.9.19
|
||||
*/
|
||||
public static final int STATUS_CONNECTION_RESET = 512;
|
||||
|
||||
/**
|
||||
* Use canned message for this status code.
|
||||
*
|
||||
* Standard codes from the router are 0-255, defined in MessageStatusMessage.
|
||||
* Standard codes from client-side I2CP are 256-511, defined in SendMessageStatusListener.
|
||||
* Standard codes from streaming are 512-767, defined here.
|
||||
*
|
||||
* @param status >= 0 from MessageStatusMessage or SendMessageStatusListener
|
||||
*/
|
||||
public I2PSocketException(int status) {
|
||||
@@ -105,6 +116,9 @@ public class I2PSocketException extends SocketException {
|
||||
case SendMessageStatusListener.STATUS_CANCELLED:
|
||||
return _x("Local destination shutdown");
|
||||
|
||||
case STATUS_CONNECTION_RESET:
|
||||
return _x("Connection was reset");
|
||||
|
||||
case CUSTOM:
|
||||
return super.getMessage();
|
||||
|
||||
|
Reference in New Issue
Block a user