Changeset ca5c15d
- Timestamp:
- Oct 11, 2008 10:28:31 AM (12 years ago)
- Branches:
- master
- Children:
- 41c38e6
- Parents:
- f3f7537
- 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 246 246 * @return the, uh, string 247 247 */ 248 @Override 248 249 public String toString() { 249 250 return new String(toByteArray()); 250 251 } 251 252 253 @Override 252 254 public int hashCode() { 253 255 int h = 0; … … 264 266 * byte arrays they contain are equal. 265 267 */ 268 @Override 266 269 public boolean equals(Object o) { 267 270 if (o instanceof ByteCollector) { -
apps/ministreaming/java/src/net/i2p/client/streaming/I2PServerSocket.java
rf3f7537 rca5c15d 13 13 /** 14 14 * Closes the socket. 15 * @throws I2PException 15 16 */ 16 17 public void close() throws I2PException; … … 32 33 /** 33 34 * Set Sock Option accept timeout 34 * @param x 35 * @param x timeout in ms 35 36 */ 36 37 public void setSoTimeout(long x); … … 38 39 /** 39 40 * Get Sock Option accept timeout 40 * @return timeout 41 * @return timeout in ms 41 42 */ 42 43 public long getSoTimeout(); … … 44 45 /** 45 46 * Access the manager which is coordinating the server socket 47 * @return I2PSocketManager 46 48 */ 47 49 public I2PSocketManager getManager(); -
apps/ministreaming/java/src/net/i2p/client/streaming/I2PServerSocketImpl.java
rf3f7537 rca5c15d 32 32 33 33 /** 34 * Set Sock Option accept timeout stub, does nothing 34 * Set Sock Option accept timeout stub, does nothing in ministreaming 35 35 * @param x 36 36 */ … … 39 39 40 40 /** 41 * Get Sock Option accept timeout stub, does nothing 41 * Get Sock Option accept timeout stub, does nothing in ministreaming 42 42 * @return timeout 43 43 */ -
apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocket.java
rf3f7537 rca5c15d 14 14 public interface I2PSocket { 15 15 /** 16 * Return the Destination of this side of the socket.16 * @return the Destination of this side of the socket. 17 17 */ 18 18 public Destination getThisDestination(); 19 19 20 20 /** 21 * Return the destination of the peer.21 * @return the destination of the peer. 22 22 */ 23 23 public Destination getPeerDestination(); 24 24 25 25 /** 26 * Return an InputStream to read from the socket. 26 * @return an InputStream to read from the socket. 27 * @throws IOException on failure 27 28 */ 28 29 public InputStream getInputStream() throws IOException; 29 30 30 31 /** 31 * Return an OutputStream to write into the socket. 32 * @return an OutputStream to write into the socket. 33 * @throws IOException on failure 32 34 */ 33 35 public OutputStream getOutputStream() throws IOException; 34 36 35 37 /** 36 * Retrieve thissocket's configuration38 * @return socket's configuration 37 39 */ 38 40 public I2PSocketOptions getOptions(); 39 41 /** 40 42 * Configure the socket 43 * @param options I2PSocketOptions to set 41 44 */ 42 45 public void setOptions(I2PSocketOptions options); … … 55 58 * I2PSocketOptions 56 59 * 60 * @param ms timeout in ms 57 61 */ 58 62 public void setReadTimeout(long ms); … … 60 64 /** 61 65 * Closes the socket if not closed yet 66 * @throws IOException on failure 62 67 */ 63 68 public void close() throws IOException; -
apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketImpl.java
rf3f7537 rca5c15d 336 336 } 337 337 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 338 342 public int read(byte[] b, int off, int len) throws IOException { 339 343 if (_log.shouldLog(Log.DEBUG)) … … 398 402 } 399 403 404 /** 405 * @return 0 if empty, > 0 if there is data. 406 */ 407 @Override 400 408 public int available() { 401 409 synchronized (bc) { … … 472 480 } 473 481 482 @Override 474 483 public void close() throws IOException { 475 484 super.close(); … … 497 506 } 498 507 508 // This override is faster than the built in JDK, 509 // but there are other variations not handled 510 @Override 499 511 public void write(byte[] b, int off, int len) throws IOException { 500 512 _bytesWritten += len; … … 502 514 } 503 515 516 @Override 504 517 public void close() { 505 518 sendTo.notifyClosed(); … … 581 594 } 582 595 596 @Override 583 597 public void run() { 584 598 byte[] buffer = new byte[MAX_PACKET_SIZE]; … … 658 672 } 659 673 674 @Override 660 675 public String toString() { return "" + hashCode(); } 661 676 } -
apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManager.java
rf3f7537 rca5c15d 49 49 * @param options I2P socket options to be used for connecting 50 50 * 51 * @return new connected socket 51 52 * @throws ConnectException if the peer refuses the connection 52 53 * @throws NoRouteToHostException if the peer is not found or not reachable … … 63 64 * @param peer Destination to connect to 64 65 * 66 * @return new connected socket 65 67 * @throws ConnectException if the peer refuses the connection 66 68 * @throws NoRouteToHostException if the peer is not found or not reachable … … 81 83 * Retrieve a set of currently connected I2PSockets, either initiated locally or remotely. 82 84 * 85 * @return a set of currently connected I2PSockets 83 86 */ 84 87 public Set listSockets(); … … 88 91 * the timeout specified, false otherwise. This call blocks. 89 92 * 93 * @param peer Destination to ping 94 * @param timeoutMs timeout in ms 95 * @return success or failure 90 96 */ 91 97 public boolean ping(Destination peer, long timeoutMs); -
apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java
rf3f7537 rca5c15d 44 44 * I2CP router on the local machine on the default port (7654). 45 45 * 46 * @param opts I2CP options 46 47 * @return the newly created socket manager, or null if there were errors 47 48 */ … … 54 55 * I2CP router on the specified host and port 55 56 * 57 * @param host I2CP host 58 * @param port I2CP port 56 59 * @return the newly created socket manager, or null if there were errors 57 60 */ … … 64 67 * I2CP router on the given machine reachable through the given port. 65 68 * 69 * @param i2cpHost I2CP host 70 * @param i2cpPort I2CP port 71 * @param opts I2CP options 66 72 * @return the newly created socket manager, or null if there were errors 67 73 */ … … 86 92 * stream and connected to the default I2CP host and port. 87 93 * 94 * @param myPrivateKeyStream private key stream 88 95 * @return the newly created socket manager, or null if there were errors 89 96 */ … … 96 103 * stream and connected to the default I2CP host and port. 97 104 * 105 * @param myPrivateKeyStream private key stream 106 * @param opts I2CP options 98 107 * @return the newly created socket manager, or null if there were errors 99 108 */ … … 107 116 * port 108 117 * 118 * @param myPrivateKeyStream private key stream 119 * @param i2cpHost I2CP host 120 * @param i2cpPort I2CP port 121 * @param opts I2CP options 109 122 * @return the newly created socket manager, or null if there were errors 110 123 */ -
apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerImpl.java
rf3f7537 rca5c15d 167 167 case DATA_IN: 168 168 sendIncoming(id, payload); 169 return; 169 170 case CHAFF: 170 171 // ignore … … 424 425 private void handleUnknown(int type, String id, byte payload[]) { 425 426 _log.error(getName() + ": \n\n=============== Unknown packet! " + "============" 426 + "\nType: " + (int)type427 + "\nType: " + type 427 428 + "\nID: " + getReadableForm(id) 428 429 + "\nBase64'ed Data: " + Base64.encode(payload) -
apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketOptions.java
rf3f7537 rca5c15d 6 6 */ 7 7 public interface I2PSocketOptions { 8 /** How much data will we accept that hasn't been written out yet. */ 8 9 public static final String PROP_BUFFER_SIZE = "i2p.streaming.bufferSize"; 10 /** How long wait for the ACK from a SYN, in milliseconds. */ 9 11 public static final String PROP_CONNECT_TIMEOUT = "i2p.streaming.connectTimeout"; 12 /** How long to block on read. */ 10 13 public static final String PROP_READ_TIMEOUT = "i2p.streaming.readTimeout"; 14 /** How long to block on write/flush */ 11 15 public static final String PROP_WRITE_TIMEOUT = "i2p.streaming.writeTimeout"; 12 16 … … 21 25 * Define how long we will wait for the ACK from a SYN, in milliseconds. 22 26 * 27 * @param ms timeout in ms 23 28 */ 24 29 public void setConnectTimeout(long ms); … … 28 33 * for more data. If this value is exceeded, the read() throws 29 34 * InterruptedIOException 35 * @return timeout in ms 30 36 */ 31 37 public long getReadTimeout(); … … 35 41 * for more data. If this value is exceeded, the read() throws 36 42 * InterruptedIOException 43 * @param ms timeout in ms 37 44 */ 38 45 public void setReadTimeout(long ms); … … 54 61 * less than or equal to zero, there is no limit (warning: can eat ram) 55 62 * 63 * @param numBytes How much data will we accept that hasn't been written out yet. 56 64 */ 57 65 public void setMaxBufferSize(int numBytes); … … 62 70 * InterruptedIOException. If this is less than or equal to zero, there 63 71 * is no timeout. 72 * @return wait time to block on the output stream while waiting for the data to flush. 64 73 */ 65 74 public long getWriteTimeout(); … … 70 79 * InterruptedIOException. If this is less than or equal to zero, there 71 80 * is no timeout. 81 * @param ms wait time to block on the output stream while waiting for the data to flush. 72 82 */ 73 83 public void setWriteTimeout(long ms); -
apps/ministreaming/java/src/net/i2p/client/streaming/StreamSinkClient.java
rf3f7537 rca5c15d 19 19 /** 20 20 * 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[]) 23 23 */ 24 24 public class StreamSinkClient { … … 125 125 * <li><b>concurrentSends</b>: how many concurrent threads should send to the server at once</li> 126 126 * </ul> 127 * @param args [i2cpHost i2cpPort] sendSizeKB writeDelayMs serverDestFile [concurrentSends] 127 128 */ 128 129 public static void main(String args[]) { -
apps/ministreaming/java/src/net/i2p/client/streaming/StreamSinkSend.java
rf3f7537 rca5c15d 111 111 * <li><b>serverDestFile</b>: file containing the StreamSinkServer's binary Destination</li> 112 112 * </ul> 113 * @param args sendFile writeDelayMs serverDestFile 113 114 */ 114 115 public static void main(String args[]) { -
apps/ministreaming/java/src/net/i2p/client/streaming/StreamSinkServer.java
rf3f7537 rca5c15d 162 162 * <li><b>numHandlers</b>: how many concurrent connections to handle</li> 163 163 * </ul> 164 * @param args [i2cpHost i2cpPort] sinkDir ourDestFile [numHandlers] 164 165 */ 165 166 public static void main(String args[]) { -
apps/ministreaming/java/src/net/i2p/client/streaming/TestSwarm.java
rf3f7537 rca5c15d 25 25 private String _destFile; 26 26 private String _peerDestFiles[]; 27 private String _conOptions;28 27 private I2PSocketManager _manager; 29 private boolean _dead; 28 private String _conOptions; // unused? used elsewhere? 29 private boolean _dead; // unused? used elsewhere? 30 30 31 31 public static void main(String args[]) {
Note: See TracChangeset
for help on using the changeset viewer.