C# Class BitSharper.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.
Inheritance: IDisposable
Afficher le fichier Open project: TangibleCryptography/BitSharper

Méthodes publiques

Méthode Description
Dispose ( ) : void
NetworkConnection ( ) : System
NetworkConnection ( IPAddress inetAddress, NetworkParameters @params, uint bestHeight, int connectTimeout ) : System
NetworkConnection ( PeerAddress peerAddress, NetworkParameters @params, uint bestHeight, int connectTimeout ) : System

Connect to the given IP address using the port specified as part of the network parameters. Once construction is complete a functioning network channel is set up and running.

Ping ( ) : void

Sends a "ping" message to the remote node. The protocol doesn't presently use this feature much.

ReadMessage ( ) : Message

Reads a network message from the wire, blocking until the message is fully received.

Shutdown ( ) : void

Shuts down the network socket. Note that there's no way to wait for a socket to be fully flushed out to the wire, so if you call this immediately after sending a message it might not get sent.

ToString ( ) : string
WriteMessage ( Message message ) : void

Writes the given message out over the network using the protocol tag. For a Transaction this should be "tx" for example. It's safe to call this from multiple threads simultaneously, the actual writing will be serialized.

Method Details

Dispose() public méthode

public Dispose ( ) : void
Résultat void

NetworkConnection() public méthode

public NetworkConnection ( ) : System
Résultat System

NetworkConnection() public méthode

public NetworkConnection ( IPAddress inetAddress, NetworkParameters @params, uint bestHeight, int connectTimeout ) : System
inetAddress System.Net.IPAddress
@params NetworkParameters
bestHeight uint
connectTimeout int
Résultat System

NetworkConnection() public méthode

Connect to the given IP address using the port specified as part of the network parameters. Once construction is complete a functioning network channel is set up and running.
If there is a network related failure. If the version negotiation failed.
public NetworkConnection ( PeerAddress peerAddress, NetworkParameters @params, uint bestHeight, int connectTimeout ) : System
peerAddress PeerAddress IP address to connect to. IPv6 is not currently supported by BitCoin. If port is not positive the default port from params is used.
@params NetworkParameters
bestHeight uint How many blocks are in our best chain
connectTimeout int Timeout in milliseconds when initially connecting to peer
Résultat System

Ping() public méthode

Sends a "ping" message to the remote node. The protocol doesn't presently use this feature much.
public Ping ( ) : void
Résultat void

ReadMessage() public méthode

Reads a network message from the wire, blocking until the message is fully received.
If the message is badly formatted, failed checksum or there was a TCP failure.
public ReadMessage ( ) : Message
Résultat Message

Shutdown() public méthode

Shuts down the network socket. Note that there's no way to wait for a socket to be fully flushed out to the wire, so if you call this immediately after sending a message it might not get sent.
public Shutdown ( ) : void
Résultat void

ToString() public méthode

public ToString ( ) : string
Résultat string

WriteMessage() public méthode

Writes the given message out over the network using the protocol tag. For a Transaction this should be "tx" for example. It's safe to call this from multiple threads simultaneously, the actual writing will be serialized.
public WriteMessage ( Message message ) : void
message Message
Résultat void