C# Класс 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.
Наследование: IDisposable
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Описание методов

Dispose() публичный Метод

public Dispose ( ) : void
Результат void

NetworkConnection() публичный Метод

public NetworkConnection ( ) : System
Результат System

NetworkConnection() публичный Метод

public NetworkConnection ( IPAddress inetAddress, NetworkParameters @params, uint bestHeight, int connectTimeout ) : System
inetAddress System.Net.IPAddress
@params NetworkParameters
bestHeight uint
connectTimeout int
Результат System

NetworkConnection() публичный Метод

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
Результат System

Ping() публичный Метод

Sends a "ping" message to the remote node. The protocol doesn't presently use this feature much.
public Ping ( ) : void
Результат void

ReadMessage() публичный Метод

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
Результат Message

Shutdown() публичный Метод

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
Результат void

ToString() публичный Метод

public ToString ( ) : string
Результат string

WriteMessage() публичный Метод

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
Результат void