com.google.bitcoin.net
Class BlockingClient

java.lang.Object
  extended by com.google.bitcoin.net.BlockingClient
All Implemented Interfaces:
MessageWriteTarget

public class BlockingClient
extends Object
implements MessageWriteTarget

Creates a simple connection to a server using a StreamParser to process data.

Generally, using NioClient and NioClientManager should be preferred over BlockingClient and BlockingClientManager, unless you wish to connect over a proxy or use some other network settings that cannot be set using NIO.


Constructor Summary
BlockingClient(SocketAddress serverAddress, StreamParser parser, int connectTimeoutMillis, SocketFactory socketFactory, Set<BlockingClient> clientSet)
          Creates a new client to the given server address using the given StreamParser to decode the data.
 
Method Summary
 void closeConnection()
          Closes the connection to the server, triggering the StreamParser.connectionClosed() event on the network-handling thread where all callbacks occur.
 void writeBytes(byte[] message)
          Writes the given bytes to the remote server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockingClient

public BlockingClient(SocketAddress serverAddress,
                      StreamParser parser,
                      int connectTimeoutMillis,
                      SocketFactory socketFactory,
                      @Nullable
                      Set<BlockingClient> clientSet)
               throws IOException

Creates a new client to the given server address using the given StreamParser to decode the data. The given parser MUST be unique to this object. This does not block while waiting for the connection to open, but will call either the StreamParser.connectionOpened() or StreamParser.connectionClosed() callback on the created network event processing thread.

Parameters:
connectTimeoutMillis - The connect timeout set on the connection (in milliseconds). 0 is interpreted as no timeout.
socketFactory - An object that creates Socket objects on demand, which may be customised to control how this client connects to the internet. If not sure, use SocketFactory.getDefault()
clientSet - A set which this object will add itself to after initialization, and then remove itself from
Throws:
IOException
Method Detail

closeConnection

public void closeConnection()
Closes the connection to the server, triggering the StreamParser.connectionClosed() event on the network-handling thread where all callbacks occur.

Specified by:
closeConnection in interface MessageWriteTarget

writeBytes

public void writeBytes(byte[] message)
                throws IOException
Description copied from interface: MessageWriteTarget
Writes the given bytes to the remote server.

Specified by:
writeBytes in interface MessageWriteTarget
Throws:
IOException


Copyright © 2014. All rights reserved.