Package org.bitcoinj.net
Class NioClient
java.lang.Object
org.bitcoinj.net.NioClient
- All Implemented Interfaces:
 MessageWriteTarget
Creates a simple connection to a server using a 
StreamConnection to process data.- 
Constructor Summary
ConstructorsConstructorDescriptionNioClient(SocketAddress serverAddress, StreamConnection parser, Duration connectTimeout) Creates a new client to the given server address using the givenStreamConnectionto decode the data. - 
Method Summary
Modifier and TypeMethodDescriptionvoidCloses the connection to the server, triggering theStreamConnection.connectionClosed()event on the network-handling thread where all callbacks occur.writeBytes(byte[] message) Writes the given bytes to the remote server. 
- 
Constructor Details
- 
NioClient
public NioClient(SocketAddress serverAddress, StreamConnection parser, Duration connectTimeout) throws IOException Creates a new client to the given server address using the given
StreamConnectionto decode the data. The given connection MUST be unique to this object. This does not block while waiting for the connection to open, but will call either theStreamConnection.connectionOpened()orStreamConnection.connectionClosed()callback on the created network event processing thread.- Parameters:
 serverAddress- socket address of the server to connect toparser- parses data from the serverconnectTimeout- timeout for establishing a connection to the server, or ZERO for no timeout- Throws:
 IOException
 
 - 
 - 
Method Details
- 
closeConnection
public void closeConnection()Description copied from interface:MessageWriteTargetCloses the connection to the server, triggering theStreamConnection.connectionClosed()event on the network-handling thread where all callbacks occur.- Specified by:
 closeConnectionin interfaceMessageWriteTarget
 - 
writeBytes
Description copied from interface:MessageWriteTargetWrites the given bytes to the remote server. The returned future will complete when all bytes have been written to the OS network buffer.- Specified by:
 writeBytesin interfaceMessageWriteTarget- Throws:
 IOException
 
 -