Changeset ca5c15d


Ignore:
Timestamp:
Oct 11, 2008 10:28:31 AM (12 years ago)
Author:
sponge <sponge@…>
Branches:
master
Children:
41c38e6
Parents:
f3f7537
Message:

Added more complete javadocs to ministreaming and cleaned up overrides so
the code is JDK5 compliant. There remains some unchecked warnings, but these
aren't important at this juncture.

Location:
apps/ministreaming/java/src/net/i2p/client/streaming
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • apps/ministreaming/java/src/net/i2p/client/streaming/ByteCollector.java

    rf3f7537 rca5c15d  
    246246     * @return the, uh, string
    247247     */
     248    @Override
    248249    public String toString() {
    249250        return new String(toByteArray());
    250251    }
    251252
     253    @Override
    252254    public int hashCode() {
    253255        int h = 0;
     
    264266     *         byte arrays they contain are equal.
    265267     */
     268    @Override
    266269    public boolean equals(Object o) {
    267270        if (o instanceof ByteCollector) {
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PServerSocket.java

    rf3f7537 rca5c15d  
    1313    /**
    1414     * Closes the socket.
     15     * @throws I2PException
    1516     */
    1617    public void close() throws I2PException;
     
    3233    /**
    3334     * Set Sock Option accept timeout
    34      * @param x
     35     * @param x timeout in ms
    3536     */
    3637    public void setSoTimeout(long x);
     
    3839    /**
    3940     * Get Sock Option accept timeout
    40      * @return timeout
     41     * @return timeout in ms
    4142     */
    4243    public long getSoTimeout();
     
    4445    /**
    4546     * Access the manager which is coordinating the server socket
     47     * @return I2PSocketManager
    4648     */
    4749    public I2PSocketManager getManager();
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PServerSocketImpl.java

    rf3f7537 rca5c15d  
    3232   
    3333    /**
    34      * Set Sock Option accept timeout stub, does nothing
     34     * Set Sock Option accept timeout stub, does nothing in ministreaming
    3535     * @param x
    3636     */
     
    3939
    4040    /**
    41      * Get Sock Option accept timeout stub, does nothing
     41     * Get Sock Option accept timeout stub, does nothing in ministreaming
    4242     * @return timeout
    4343     */
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocket.java

    rf3f7537 rca5c15d  
    1414public interface I2PSocket {
    1515    /**
    16      * Return the Destination of this side of the socket.
     16     * @return the Destination of this side of the socket.
    1717     */
    1818    public Destination getThisDestination();
    1919
    2020    /**
    21      * Return the destination of the peer.
     21     * @return the destination of the peer.
    2222     */
    2323    public Destination getPeerDestination();
    2424
    2525    /**
    26      * Return an InputStream to read from the socket.
     26     * @return an InputStream to read from the socket.
     27     * @throws IOException on failure
    2728     */
    2829    public InputStream getInputStream() throws IOException;
    2930
    3031    /**
    31      * Return an OutputStream to write into the socket.
     32     * @return an OutputStream to write into the socket.
     33     * @throws IOException on failure
    3234     */
    3335    public OutputStream getOutputStream() throws IOException;
    3436
    3537    /**
    36      * Retrieve this socket's configuration
     38     * @return socket's configuration
    3739     */
    3840    public I2PSocketOptions getOptions();
    3941    /**
    4042     * Configure the socket
     43     * @param options I2PSocketOptions to set
    4144     */
    4245    public void setOptions(I2PSocketOptions options);
     
    5558     * I2PSocketOptions
    5659     *
     60     * @param ms timeout in ms
    5761     */
    5862    public void setReadTimeout(long ms);
     
    6064    /**
    6165     * Closes the socket if not closed yet
     66     * @throws IOException on failure
    6267     */
    6368    public void close() throws IOException;
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketImpl.java

    rf3f7537 rca5c15d  
    336336        }
    337337
     338        // I have to ask if this method is really needed, since the JDK has this already,
     339        // including the timeouts. Perhaps the need is for debugging more than anything
     340        // else?
     341        @Override
    338342        public int read(byte[] b, int off, int len) throws IOException {
    339343            if (_log.shouldLog(Log.DEBUG))
     
    398402        }
    399403
     404        /**
     405         * @return 0 if empty, > 0 if there is data.
     406         */
     407        @Override
    400408        public int available() {
    401409            synchronized (bc) {
     
    472480        }
    473481       
     482        @Override
    474483        public void close() throws IOException {
    475484            super.close();
     
    497506        }
    498507
     508        // This override is faster than the built in JDK,
     509        // but there are other variations not handled
     510        @Override
    499511        public void write(byte[] b, int off, int len) throws IOException {
    500512            _bytesWritten += len;
     
    502514        }
    503515
     516        @Override
    504517        public void close() {
    505518            sendTo.notifyClosed();
     
    581594        }
    582595
     596        @Override
    583597        public void run() {
    584598            byte[] buffer = new byte[MAX_PACKET_SIZE];
     
    658672    }
    659673   
     674    @Override
    660675    public String toString() { return "" + hashCode(); }
    661676}
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManager.java

    rf3f7537 rca5c15d  
    4949     * @param options I2P socket options to be used for connecting
    5050     *
     51     * @return new connected socket
    5152     * @throws ConnectException if the peer refuses the connection
    5253     * @throws NoRouteToHostException if the peer is not found or not reachable
     
    6364     * @param peer Destination to connect to
    6465     *
     66     * @return new connected socket
    6567     * @throws ConnectException if the peer refuses the connection
    6668     * @throws NoRouteToHostException if the peer is not found or not reachable
     
    8183     * Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.
    8284     *
     85     * @return a set of currently connected I2PSockets
    8386     */
    8487    public Set listSockets();
     
    8891     * the timeout specified, false otherwise.  This call blocks.
    8992     *
     93     * @param peer Destination to ping
     94     * @param timeoutMs timeout in ms
     95     * @return success or failure
    9096     */
    9197    public boolean ping(Destination peer, long timeoutMs);
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java

    rf3f7537 rca5c15d  
    4444     * I2CP router on the local machine on the default port (7654).
    4545     *
     46     * @param opts I2CP options
    4647     * @return the newly created socket manager, or null if there were errors
    4748     */
     
    5455     * I2CP router on the specified host and port
    5556     *
     57     * @param host I2CP host
     58     * @param port I2CP port
    5659     * @return the newly created socket manager, or null if there were errors
    5760     */
     
    6467     * I2CP router on the given machine reachable through the given port.
    6568     *
     69     * @param i2cpHost I2CP host
     70     * @param i2cpPort I2CP port
     71     * @param opts I2CP options
    6672     * @return the newly created socket manager, or null if there were errors
    6773     */
     
    8692     * stream and connected to the default I2CP host and port.
    8793     *
     94     * @param myPrivateKeyStream private key stream
    8895     * @return the newly created socket manager, or null if there were errors
    8996     */
     
    96103     * stream and connected to the default I2CP host and port.
    97104     *
     105     * @param myPrivateKeyStream private key stream
     106     * @param opts I2CP options
    98107     * @return the newly created socket manager, or null if there were errors
    99108     */
     
    107116     * port
    108117     *
     118     * @param myPrivateKeyStream private key stream
     119     * @param i2cpHost I2CP host
     120     * @param i2cpPort I2CP port
     121     * @param opts I2CP options
    109122     * @return the newly created socket manager, or null if there were errors
    110123     */
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerImpl.java

    rf3f7537 rca5c15d  
    167167                case DATA_IN:
    168168                    sendIncoming(id, payload);
     169                    return;
    169170                case CHAFF:
    170171                    // ignore
     
    424425    private void handleUnknown(int type, String id, byte payload[]) {
    425426        _log.error(getName() + ": \n\n=============== Unknown packet! " + "============"
    426                    + "\nType: " + (int) type
     427                   + "\nType: " + type
    427428                   + "\nID:   " + getReadableForm(id)
    428429                   + "\nBase64'ed Data: " + Base64.encode(payload)
  • apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketOptions.java

    rf3f7537 rca5c15d  
    66 */
    77public interface I2PSocketOptions {
     8    /** How much data will we accept that hasn't been written out yet. */
    89    public static final String PROP_BUFFER_SIZE = "i2p.streaming.bufferSize";
     10    /** How long wait for the ACK from a SYN, in milliseconds. */
    911    public static final String PROP_CONNECT_TIMEOUT = "i2p.streaming.connectTimeout";
     12    /** How long to block on read. */
    1013    public static final String PROP_READ_TIMEOUT = "i2p.streaming.readTimeout";
     14    /** How long to block on write/flush */
    1115    public static final String PROP_WRITE_TIMEOUT = "i2p.streaming.writeTimeout";
    1216   
     
    2125     * Define how long we will wait for the ACK from a SYN, in milliseconds.
    2226     *
     27     * @param ms timeout in ms
    2328     */
    2429    public void setConnectTimeout(long ms);
     
    2833     * for more data.  If this value is exceeded, the read() throws
    2934     * InterruptedIOException
     35     * @return timeout in ms
    3036     */
    3137    public long getReadTimeout();
     
    3541     * for more data.  If this value is exceeded, the read() throws
    3642     * InterruptedIOException
     43     * @param ms timeout in ms
    3744     */
    3845    public void setReadTimeout(long ms);
     
    5461     * less than or equal to zero, there is no limit (warning: can eat ram)
    5562     *
     63     * @param numBytes How much data will we accept that hasn't been written out yet.
    5664     */
    5765    public void setMaxBufferSize(int numBytes);
     
    6270     * InterruptedIOException.  If this is less than or equal to zero, there
    6371     * is no timeout.
     72     * @return wait time to block on the output stream while waiting for the data to flush.
    6473     */
    6574    public long getWriteTimeout();
     
    7079     * InterruptedIOException.  If this is less than or equal to zero, there
    7180     * is no timeout.
     81     * @param ms wait time to block on the output stream while waiting for the data to flush.
    7282     */
    7383    public void setWriteTimeout(long ms);
  • apps/ministreaming/java/src/net/i2p/client/streaming/StreamSinkClient.java

    rf3f7537 rca5c15d  
    1919/**
    2020 * Simple streaming lib test app that connects to a given destination and sends
    21  * it a particular amount of random data, then disconnects.  See the {@link #main}
    22  *
     21 * it a particular amount of random data, then disconnects.
     22 * @see #main(java.lang.String[])
    2323 */
    2424public class StreamSinkClient {
     
    125125     *  <li><b>concurrentSends</b>: how many concurrent threads should send to the server at once</li>
    126126     * </ul>
     127     * @param args [i2cpHost i2cpPort] sendSizeKB writeDelayMs serverDestFile [concurrentSends]
    127128     */
    128129    public static void main(String args[]) {
  • apps/ministreaming/java/src/net/i2p/client/streaming/StreamSinkSend.java

    rf3f7537 rca5c15d  
    111111     *  <li><b>serverDestFile</b>: file containing the StreamSinkServer's binary Destination</li>
    112112     * </ul>
     113     * @param args sendFile writeDelayMs serverDestFile
    113114     */
    114115    public static void main(String args[]) {
  • apps/ministreaming/java/src/net/i2p/client/streaming/StreamSinkServer.java

    rf3f7537 rca5c15d  
    162162     *  <li><b>numHandlers</b>: how many concurrent connections to handle</li>
    163163     * </ul>
     164     * @param args [i2cpHost i2cpPort] sinkDir ourDestFile [numHandlers]
    164165     */
    165166    public static void main(String args[]) {
  • apps/ministreaming/java/src/net/i2p/client/streaming/TestSwarm.java

    rf3f7537 rca5c15d  
    2525    private String _destFile;
    2626    private String _peerDestFiles[];
    27     private String _conOptions;
    2827    private I2PSocketManager _manager;
    29     private boolean _dead;
     28    private String _conOptions; // unused? used elsewhere?
     29    private boolean _dead; // unused? used elsewhere?
    3030   
    3131    public static void main(String args[]) {
Note: See TracChangeset for help on using the changeset viewer.