Table of Contents

Interface ITcpService

Namespace
NLightning.Infrastructure.Transport.Interfaces
Assembly
NLightning.Infrastructure.dll
public interface ITcpService

Methods

ConnectToPeerAsync(PeerAddressInfo)

Establishes a connection to a peer specified by the provided address information.

Task<ConnectedPeer> ConnectToPeerAsync(PeerAddressInfo peerAddressInfo)

Parameters

peerAddressInfo PeerAddressInfo

The address information of the peer to connect to.

Returns

Task<ConnectedPeer>

A task representing the asynchronous operation. The result contains a ConnectedPeer object representing the connected peer.

StartListeningAsync(CancellationToken)

Starts the TCP listener service and begins listening for incoming connections on the configured addresses.

Task StartListeningAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A token to monitor for cancellation requests, which can be used to stop listening.

Returns

Task

A task representing the asynchronous operation.

StopListeningAsync()

Stops the TCP listener service and cleans up all active listeners, ensuring that no further connections can be made.

Task StopListeningAsync()

Returns

Task

A task representing the asynchronous operation.

Events

OnNewPeerConnected

Event triggered when a new peer successfully establishes a connection.

event EventHandler<NewPeerConnectedEventArgs> OnNewPeerConnected

Event Type

EventHandler<NewPeerConnectedEventArgs>

Remarks

This event provides the means to handle actions or logic that should occur when a new peer connects to the TCP listener.