mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 14:51:41 +01:00
33 lines
740 B
C#
33 lines
740 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Net;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
namespace Capnp.Net.Runtime.Tests.Util
|
|||
|
{
|
|||
|
class TcpManager
|
|||
|
{
|
|||
|
public static readonly TcpManager Instance = new TcpManager();
|
|||
|
|
|||
|
readonly byte[] _nextAddress;
|
|||
|
int _nextPort = 50005;
|
|||
|
|
|||
|
public TcpManager()
|
|||
|
{
|
|||
|
_nextAddress = new byte[] { 127, 0, 0, 1 };
|
|||
|
}
|
|||
|
|
|||
|
public (IPAddress, int) GetLocalAddressAndPort()
|
|||
|
{
|
|||
|
if (++_nextAddress[2] == 0 &&
|
|||
|
++_nextAddress[1] == 0 &&
|
|||
|
++_nextAddress[0] == 0)
|
|||
|
{
|
|||
|
_nextAddress[0] = 2;
|
|||
|
}
|
|||
|
|
|||
|
return (new IPAddress(_nextAddress), _nextPort);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|