Skip to content

Commit f002c02

Browse files
committed
Move localhost IP address into constant
1 parent d0101ad commit f002c02

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

SerializersBenchmark/Network/Abstractions/TcpServer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ namespace SerializersBenchmark.Network.Abstractions;
55

66
public abstract class TcpServer(int port) : IServer
77
{
8-
private readonly TcpListener _tcpListener = new(IPAddress.Parse("127.0.0.1"), port);
8+
public const string LOCALHOST = "127.0.0.1";
9+
private readonly TcpListener _tcpListener = new(IPAddress.Parse(LOCALHOST), port);
910
private TcpClient _connectedClient;
1011
protected bool TeardownStarted;
1112

SerializersBenchmark/Network/Rabbit.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public Rabbit(ISerializerTestAsync serializer, int port, bool useBufferedStream
1616
_port = port;
1717
_useBufferedStream = useBufferedStream;
1818
_tcpClient = new TcpClient();
19-
_tcpClient.Client.NoDelay = true; //disable Nagle's algorithm for low latency
19+
_tcpClient.Client.NoDelay = true; // disable Nagle's algorithm for low latency
2020
}
2121

2222
public async Task ConnectAsync() {
23-
await _tcpClient.ConnectAsync("127.0.0.1", _port);
23+
await _tcpClient.ConnectAsync(TcpServer.LOCALHOST, _port).ConfigureAwait(false);
2424
_networkStream = _tcpClient.GetStream();
2525
}
2626

0 commit comments

Comments
 (0)