Class SessionParams

java.lang.Object
com.frostwire.jlibtorrent.SessionParams

public class SessionParams extends Object
Configuration parameters for initializing a bittorrent session.

SessionParams encapsulates all settings and options needed to configure a new libtorrent session before calling SessionManager.start(SessionParams). It holds both general settings and advanced options like disk I/O backend selection.

Creating SessionParams:

 // With default settings
 SessionParams params = new SessionParams();

 // With custom settings
 SessionParams params = new SessionParams();
 SettingsPack settings = params.getSettings();
 settings.downloadRateLimit(1000);     // 1 MB/s max
 settings.uploadRateLimit(500);        // 500 KB/s max
 settings.activeDownloads(3);          // Max 3 concurrent downloads
 settings.connectionsLimit(200);       // Max 200 connections
 // ... more settings ...

 // From saved session state
 SessionParams params = new SessionParams(new File("session-state.bin"));
 

Default Configuration: When using the default constructor, SessionParams activates:

  • Default plugins (ut_metadata, ut_pex, smart_ban)
  • UPnP port mapping (for NAT traversal)
  • NAT-PMP port mapping (Apple/AirPort compatible)
  • DHT (Distributed Hash Table)
  • LSD (Local Service Discovery)

Storage Backend Selection: By default, jlibtorrent uses memory-mapped I/O for fast disk access. For compatibility with systems that don't support it (e.g., some Android devices), use POSIX disk I/O:

 SessionParams params = new SessionParams();
 params.setPosixDiskIO(); // Use portable POSIX file I/O instead of mmap
 sm.start(params);
 

Session State Persistence: You can save and restore session state (known peers, DHT nodes, etc.) by:

 // Save state from a running session
 byte[] state = sm.swig().session_state();
 Files.write(Paths.get("session-state.bin"), state);

 // Restore state in new SessionManager instance
 SessionParams params = new SessionParams(new File("session-state.bin"));
 sessionManager2.start(params);
 

Performance Tuning: Via the embedded , you can tune:

  • Bandwidth limits (downloadRateLimit, uploadRateLimit)
  • Connection limits (connectionsLimit, maxPeerlistSize)
  • Active torrent limits (activeDownloads, activeSeeds)
  • Encryption settings (incomingEncryption, outgoingEncryption)
  • Announce interval and timing
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    This constructor can be used to start with the default plugins (ut_metadata, ut_pex and smart_ban).
    SessionParams(byte[] data)
     
    This constructor can be used to start with the default plugins (ut_metadata, ut_pex and smart_ban).
    SessionParams(com.frostwire.jlibtorrent.swig.session_params p)
     
    This constructor can be used to start with the default plugins (ut_metadata, ut_pex and smart_ban).
  • Method Summary

    Modifier and Type
    Method
    Description
     
    void
    Internally set the session to use the more appropriate disk I/O back-end.
    void
    Internally set the session to use a simple posix disk I/O back-end, used for systems that don't have a 64-bit virtual address space or don't support memory mapped files.
    void
    The settings to configure the session with.
    com.frostwire.jlibtorrent.swig.session_params
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SessionParams

      public SessionParams(com.frostwire.jlibtorrent.swig.session_params p)
      Parameters:
      p - the native object
    • SessionParams

      public SessionParams()
      This constructor can be used to start with the default plugins (ut_metadata, ut_pex and smart_ban). The default values in the settings is to start the default features like upnp, nat-pmp, and dht for example.
    • SessionParams

      public SessionParams(File data)
      This constructor can be used to start with the default plugins (ut_metadata, ut_pex and smart_ban). The default values in the settings is to start the default features like upnp, nat-pmp, and dht for example.
    • SessionParams

      public SessionParams(byte[] data)
    • SessionParams

      public SessionParams(SettingsPack settings)
      This constructor can be used to start with the default plugins (ut_metadata, ut_pex and smart_ban). The default values in the settings is to start the default features like upnp, nat-pmp, and dht for example.
      Parameters:
      settings - the initial settings pack
  • Method Details

    • swig

      public com.frostwire.jlibtorrent.swig.session_params swig()
      Returns:
      the native object
    • getSettings

      public SettingsPack getSettings()
      Returns:
      the settings pack
    • setSettings

      public void setSettings(SettingsPack settings)
      The settings to configure the session with.
      Parameters:
      settings - the settings pack
    • setPosixDiskIO

      public void setPosixDiskIO()
      Internally set the session to use a simple posix disk I/O back-end, used for systems that don't have a 64-bit virtual address space or don't support memory mapped files. It's implemented using portable C file functions and is single-threaded. This is an advance feature, only to use in particular situations, like Android devices with faulty drivers.
    • setDefaultDiskIO

      public void setDefaultDiskIO()
      Internally set the session to use the more appropriate disk I/O back-end. On systems that support memory mapped files (and a 64-bit address space) the memory mapped storage will be constructed, otherwise the portable posix storage.