Package org.bitcoinj.net
Class BlockingClientManager
- java.lang.Object
 - 
- com.google.common.util.concurrent.AbstractIdleService
 - 
- org.bitcoinj.net.BlockingClientManager
 
 
 
- 
- All Implemented Interfaces:
 com.google.common.util.concurrent.Service,ClientConnectionManager
public class BlockingClientManager extends com.google.common.util.concurrent.AbstractIdleService implements ClientConnectionManager
A thin wrapper around a set of
BlockingClients.Generally, using
NioClientandNioClientManagershould be preferred overBlockingClientandBlockingClientManageras they scale significantly better, unless you wish to connect over a proxy or use some other network settings that cannot be set using NIO. 
- 
- 
Constructor Summary
Constructors Constructor Description BlockingClientManager()BlockingClientManager(javax.net.SocketFactory socketFactory)Creates a blocking client manager that will obtain sockets from the given factory. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseConnections(int n)Closes n peer connectionsintgetConnectedClientCount()Gets the number of connected peerscom.google.common.util.concurrent.ListenableFuture<java.net.SocketAddress>openConnection(java.net.SocketAddress serverAddress, StreamConnection connection)Creates a new connection to the given address, with the given connection used to handle incoming data.voidsetConnectTimeoutMillis(int connectTimeoutMillis)Sets the number of milliseconds to wait before giving up on a connect attemptprotected voidshutDown()protected voidstartUp()- 
Methods inherited from class com.google.common.util.concurrent.AbstractIdleService
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, startAsync, state, stopAsync, toString 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
BlockingClientManager
public BlockingClientManager()
 
- 
BlockingClientManager
public BlockingClientManager(javax.net.SocketFactory socketFactory)
Creates a blocking client manager that will obtain sockets from the given factory. Useful for customising how bitcoinj connects to the P2P network. 
 - 
 
- 
Method Detail
- 
openConnection
public com.google.common.util.concurrent.ListenableFuture<java.net.SocketAddress> openConnection(java.net.SocketAddress serverAddress, StreamConnection connection)Description copied from interface:ClientConnectionManagerCreates a new connection to the given address, with the given connection used to handle incoming data. Any errors that occur during connection will be returned in the given future, including errors that can occur immediately.- Specified by:
 openConnectionin interfaceClientConnectionManager
 
- 
setConnectTimeoutMillis
public void setConnectTimeoutMillis(int connectTimeoutMillis)
Sets the number of milliseconds to wait before giving up on a connect attempt 
- 
startUp
protected void startUp() throws java.lang.Exception- Specified by:
 startUpin classcom.google.common.util.concurrent.AbstractIdleService- Throws:
 java.lang.Exception
 
- 
shutDown
protected void shutDown() throws java.lang.Exception- Specified by:
 shutDownin classcom.google.common.util.concurrent.AbstractIdleService- Throws:
 java.lang.Exception
 
- 
getConnectedClientCount
public int getConnectedClientCount()
Description copied from interface:ClientConnectionManagerGets the number of connected peers- Specified by:
 getConnectedClientCountin interfaceClientConnectionManager
 
- 
closeConnections
public void closeConnections(int n)
Description copied from interface:ClientConnectionManagerCloses n peer connections- Specified by:
 closeConnectionsin interfaceClientConnectionManager
 
 - 
 
 -