Example #1
0
 public async void Start()
 {
     if (Interlocked.Exchange(ref started, 1) == 0)
     {
         connectThread.Start();
         listener.Start();
         while (disposed == 0)
         {
             TcpClient tcp;
             try
             {
                 tcp = await listener.AcceptTcpClientAsync();
             }
             catch (ObjectDisposedException)
             {
                 continue;
             }
             RemoteNode remoteNode = new RemoteNode(this, tcp);
             lock (pendingPeers)
             {
                 pendingPeers.Add(remoteNode);
             }
             remoteNode.StartProtocol();
         }
     }
 }
Example #2
0
 private void AcceptPeersLoop()
 {
     while (disposed == 0)
     {
         TcpClient tcp;
         try
         {
             tcp = listener.AcceptTcpClient();
         }
         catch (ObjectDisposedException)
         {
             break;
         }
         catch (SocketException)
         {
             break;
         }
         RemoteNode remoteNode = new RemoteNode(this, tcp);
         lock (pendingPeers)
         {
             pendingPeers.Add(remoteNode);
         }
         remoteNode.Disconnected        += RemoteNode_Disconnected;
         remoteNode.PeersReceived       += RemoteNode_PeersReceived;
         remoteNode.BlockReceived       += RemoteNode_BlockReceived;
         remoteNode.TransactionReceived += RemoteNode_TransactionReceived;
         remoteNode.StartProtocol();
     }
 }
Example #3
0
 private void OnConnected(RemoteNode remoteNode)
 {
     lock (connectedPeers)
     {
         connectedPeers.Add(remoteNode);
     }
     remoteNode.Disconnected      += RemoteNode_Disconnected;
     remoteNode.InventoryReceived += RemoteNode_InventoryReceived;
     remoteNode.PeersReceived     += RemoteNode_PeersReceived;
     remoteNode.StartProtocol();
 }
Example #4
0
 private async Task AcceptPeersAsync()
 {
     while (disposed == 0)
     {
         Socket socket;
         try
         {
             socket = await listener.AcceptSocketAsync();
         }
         catch (ObjectDisposedException)
         {
             break;
         }
         catch (SocketException)
         {
             break;
         }
         RemoteNode remoteNode = new RemoteNode(this, socket);
         remoteNode.Disconnected      += RemoteNode_Disconnected;
         remoteNode.InventoryReceived += RemoteNode_InventoryReceived;
         remoteNode.PeersReceived     += RemoteNode_PeersReceived;
         remoteNode.StartProtocol();
     }
 }
Example #5
0
 private void AcceptPeersLoop()
 {
     while (disposed == 0)
     {
         TcpClient tcp;
         try
         {
             tcp = listener.AcceptTcpClient();
         }
         catch (ObjectDisposedException)
         {
             break;
         }
         catch (SocketException)
         {
             break;
         }
         RemoteNode remoteNode = new RemoteNode(this, tcp);
         remoteNode.Disconnected      += RemoteNode_Disconnected;
         remoteNode.InventoryReceived += RemoteNode_InventoryReceived;
         remoteNode.PeersReceived     += RemoteNode_PeersReceived;
         remoteNode.StartProtocol();
     }
 }
Example #6
0
 public async void Start()
 {
     if (Interlocked.Exchange(ref started, 1) == 0)
     {
         connectWorker.Start();
         listener.Start();
         while (disposed == 0)
         {
             TcpClient tcp;
             try
             {
                 tcp = await listener.AcceptTcpClientAsync();
             }
             catch (ObjectDisposedException)
             {
                 continue;
             }
             RemoteNode remoteNode = new RemoteNode(this, tcp);
             lock (pendingPeers)
             {
                 pendingPeers.Add(remoteNode);
             }
             remoteNode.StartProtocol();
         }
     }
 }
Example #7
0
 private void AcceptPeersLoop()
 {
     while (disposed == 0)
     {
         TcpClient tcp;
         try
         {
             tcp = listener.AcceptTcpClient();
         }
         catch (ObjectDisposedException)
         {
             break;
         }
         catch (SocketException)
         {
             break;
         }
         RemoteNode remoteNode = new RemoteNode(this, tcp);
         lock (pendingPeers)
         {
             pendingPeers.Add(remoteNode);
         }
         remoteNode.Disconnected += RemoteNode_Disconnected;
         remoteNode.PeersReceived += RemoteNode_PeersReceived;
         remoteNode.BlockReceived += RemoteNode_BlockReceived;
         remoteNode.TransactionReceived += RemoteNode_TransactionReceived;
         remoteNode.StartProtocol();
     }
 }