## net.i2p.client.streaming
Interface I2PSocketManager

All Known Implementing Classes:
  I2PSocketManagerFull, I2PSocketManagerImpl

    public interface I2PSocketManager

Centralize the coordination and multiplexing of the local client's streaming. There should be one I2PSocketManager for each I2PSession, and if an application is sending and receiving data through the streaming library using an I2PSocketManager, it should not attempt to call I2PSession's setSessionListener or receive any messages with its .receiveMessage

Nested Class Summary
`static interface` `I2PSocketManager.DisconnectListener`

Method Summary
`void` `addDisconnectListener(I2PSocketManager.DisconnectListener lsnr)`
`I2PSocketOptions` `buildOptions()`
`I2PSocketOptions` `buildOptions(Properties opts)`
`I2PSocket` `connect(Destination peer)` Create a new connected socket (block until the socket is created)
`I2PSocket` `connect(Destination peer, I2PSocketOptions options)` Create a new connected socket (block until the socket is created)
`Socket` `connectToSocket(Destination peer)` Like connect() but returns a real Socket, and throws only IOE, for easier porting of apps.
`Socket` `connectToSocket(Destination peer, int timeout)` Like connect() but returns a real Socket, and throws only IOE, for easier porting of apps.
`void` `destroySocketManager()` Destroy the socket manager, freeing all the associated resources.
`long` `getAcceptTimeout()`
`I2PSocketOptions` `getDefaultOptions()`
`String` `getName()`
`I2PServerSocket` `getServerSocket()`
`I2PSession` `getSession()`
`ServerSocket` `getStandardServerSocket()` Like getServerSocket but returns a real ServerSocket for easier porting of apps.
`void` `init(I2PAppContext context, I2PSession session, Properties opts, String name)`
`Set<I2PSocket>` `listSockets()` Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.
`boolean` `ping(Destination peer, long timeoutMs)` Ping the specified peer, returning true if they replied to the ping within the timeout specified, false otherwise.
`void` `removeDisconnectListener(I2PSocketManager.DisconnectListener lsnr)`
`void` `setAcceptTimeout(long ms)` How long should we wait for the client to .accept() a socket before sending back a NACK/Close?
`void` `setDefaultOptions(I2PSocketOptions options)`
`void` `setName(String name)`

Method Detail

### getSession

    I2PSession getSession()

### setAcceptTimeout

    void setAcceptTimeout(long ms)

  How long should we wait for the client to .accept() a socket before sending back a NACK/Close?

  Parameters:
    `ms` - milliseconds to wait, maximum

### getAcceptTimeout

    long getAcceptTimeout()

### setDefaultOptions

    void setDefaultOptions(I2PSocketOptions options)

### getDefaultOptions

    I2PSocketOptions getDefaultOptions()

### getServerSocket

    I2PServerSocket getServerSocket()

### buildOptions

    I2PSocketOptions buildOptions()

### buildOptions

    I2PSocketOptions buildOptions(Properties opts)

### connect

    I2PSocket connect(Destination peer,
                      I2PSocketOptions options)
                      throws I2PException,
                             ConnectException,
                             NoRouteToHostException,
                             InterruptedIOException

  Create a new connected socket (block until the socket is created)

  Parameters:
    `peer` - Destination to connect to
    `options` - I2P socket options to be used for connecting
  Returns:
    new connected socket
  Throws:
    `ConnectException` - if the peer refuses the connection
    `NoRouteToHostException` - if the peer is not found or not reachable
    `InterruptedIOException` - if the connection timeouts
    `I2PException` - if there is some other I2P-related problem

### connect

    I2PSocket connect(Destination peer)
                      throws I2PException,
                             ConnectException,
                             NoRouteToHostException,
                             InterruptedIOException

  Create a new connected socket (block until the socket is created)

  Parameters:
    `peer` - Destination to connect to
  Returns:
    new connected socket
  Throws:
    `ConnectException` - if the peer refuses the connection
    `NoRouteToHostException` - if the peer is not found or not reachable
    `InterruptedIOException` - if the connection timeouts
    `I2PException` - if there is some other I2P-related problem

### destroySocketManager

    void destroySocketManager()

  Destroy the socket manager, freeing all the associated resources. This method will block untill all the managed sockets are closed.

### listSockets

    Set<I2PSocket> listSockets()

  Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.

  Returns:
    a set of currently connected I2PSockets

### ping

    boolean ping(Destination peer,
                 long timeoutMs)

  Ping the specified peer, returning true if they replied to the ping within the timeout specified, false otherwise. This call blocks.

  Parameters:
    `peer` - Destination to ping
    `timeoutMs` - timeout in ms
  Returns:
    success or failure

### getName

    String getName()

### setName

    void setName(String name)

### init

    void init(I2PAppContext context,
              I2PSession session,
              Properties opts,
              String name)

### addDisconnectListener

    void addDisconnectListener(I2PSocketManager.DisconnectListener lsnr)

### removeDisconnectListener

    void removeDisconnectListener(I2PSocketManager.DisconnectListener lsnr)

### getStandardServerSocket

    ServerSocket getStandardServerSocket()
                                         throws IOException

  Like getServerSocket but returns a real ServerSocket for easier porting of apps.

  Throws:
    `IOException`
  Since:
    0.8.4

### connectToSocket

    Socket connectToSocket(Destination peer)
                           throws IOException

  Like connect() but returns a real Socket, and throws only IOE, for easier porting of apps.

  Throws:
    `IOException`
  Since:
    0.8.4

### connectToSocket

    Socket connectToSocket(Destination peer,
                           int timeout)
                           throws IOException

  Like connect() but returns a real Socket, and throws only IOE, for easier porting of apps.

  Parameters:
    `timeout` - ms if > 0, forces blocking (disables connectDelay)
  Throws:
    `IOException`
  Since:
    0.8.4