|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.bitcoin.core.NetworkConnection
public class NetworkConnection
A NetworkConnection handles talking to a remote BitCoin peer at a low level. It understands how to read and write
messages off the network, but doesn't asynchronously communicate with the peer or handle the higher level details
of the protocol. After constructing a NetworkConnection, use a Peer
to hand off communication to a
background thread.
Construction is blocking whilst the protocol version is negotiated.
Constructor Summary | |
---|---|
NetworkConnection(InetAddress remoteIp,
NetworkParameters params,
int bestHeight,
int connectTimeout)
Connect to the given IP address using the port specified as part of the network parameters. |
Method Summary | |
---|---|
VersionMessage |
getVersionMessage()
Returns the version message received from the other end of the connection during the handshake. |
void |
ping()
Sends a "ping" message to the remote node. |
Message |
readMessage()
Reads a network message from the wire, blocking until the message is fully received. |
void |
shutdown()
Shuts down the network socket. |
String |
toString()
|
void |
writeMessage(Message message)
Writes the given message out over the network using the protocol tag. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NetworkConnection(InetAddress remoteIp, NetworkParameters params, int bestHeight, int connectTimeout) throws IOException, ProtocolException
remoteIp
- IP address to connect to. IPv6 is not currently supported by BitCoin.params
- Defines which network to connect to and details of the protocol.bestHeight
- How many blocks are in our best chainconnectTimeout
- Timeout in milliseconds when initially connecting to peer
IOException
- if there is a network related failure.
ProtocolException
- if the version negotiation failed.Method Detail |
---|
public void ping() throws IOException
IOException
public void shutdown() throws IOException
IOException
public String toString()
toString
in class Object
public Message readMessage() throws IOException, ProtocolException
ProtocolException
- if the message is badly formatted, failed checksum or there was a TCP failure.
IOException
public void writeMessage(Message message) throws IOException
IOException
public VersionMessage getVersionMessage()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |