Skip to content

Latest commit

 

History

History
31 lines (31 loc) · 750 Bytes

20181123.五次重试.md

File metadata and controls

31 lines (31 loc) · 750 Bytes
while(true)
{
	try
	{
		var a = _Rand.Next(4000, 60000);
		var b = _Rand.Next(4000, 60000);
		_Server1 = new NodeServer(network, internalPort: a);
		_Server1.AllowLocalPeers = true;
		_Server1.ExternalEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1").MapToIPv6Ex(), a);
		_Server1.Listen();
		Assert.True(_Server1.IsListening);
		_Server2 = new NodeServer(network, internalPort: b);
		_Server2.AllowLocalPeers = true;
		_Server2.ExternalEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1").MapToIPv6Ex(), b);
		_Server2.Listen();
		Assert.True(_Server2.IsListening);
		break;
	}
	catch(Exception)
	{
		if(_Server1 != null)
			_Server1.Dispose();
		if(_Server2 != null)
			_Server2.Dispose();
		retry++;
		if(retry == 5)
			throw;
	}
}