Skip to content

Commit

Permalink
Where is the right place to config socket buffer size #58
Browse files Browse the repository at this point in the history
  • Loading branch information
chronoxor committed Apr 24, 2020
1 parent 180e99c commit fd4fdc0
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 243 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Specify version format
version: "3.0.11.{build}"
version: "3.0.12.{build}"

# Image to use
image: Visual Studio 2019
Expand Down
2 changes: 1 addition & 1 deletion source/NetCoreServer/NetCoreServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>3.0.11</Version>
<Version>3.0.12</Version>
<Authors>Ivan Shynkarenka</Authors>
<Copyright>Copyright (c) 2019-2020 Ivan Shynkarenka</Copyright>
<RepositoryUrl>https://github.com/chronoxor/NetCoreServer</RepositoryUrl>
Expand Down
42 changes: 2 additions & 40 deletions source/NetCoreServer/SslClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,49 +98,11 @@ public SslClient(SslContext context, IPEndPoint endpoint)
/// <summary>
/// Option: receive buffer size
/// </summary>
public int OptionReceiveBufferSize
{
get => Socket.ReceiveBufferSize;
set => Socket.ReceiveBufferSize = value;
}
public int OptionReceiveBufferSize { get; set; } = 8192;
/// <summary>
/// Option: send buffer size
/// </summary>
public int OptionSendBufferSize
{
get => Socket.SendBufferSize;
set => Socket.SendBufferSize = value;
}
/// <summary>
/// Option: receive timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionReceiveTimeout
{
get => Socket.ReceiveTimeout;
set => Socket.ReceiveTimeout = value;
}
/// <summary>
/// Option: send timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionSendTimeout
{
get => Socket.SendTimeout;
set => Socket.SendTimeout = value;
}
/// <summary>
/// Option: linger state
/// </summary>
public LingerOption OptionLingerState
{
get => Socket.LingerState;
set => Socket.LingerState = value;
}
public int OptionSendBufferSize { get; set; } = 8192;

#region Connect/Disconnect client

Expand Down
8 changes: 8 additions & 0 deletions source/NetCoreServer/SslServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ public SslServer(SslContext context, IPEndPoint endpoint)
/// This option will enable/disable SO_EXCLUSIVEADDRUSE if the OS support this feature
/// </remarks>
public bool OptionExclusiveAddressUse { get; set; }
/// <summary>
/// Option: receive buffer size
/// </summary>
public int OptionReceiveBufferSize { get; set; } = 8192;
/// <summary>
/// Option: send buffer size
/// </summary>
public int OptionSendBufferSize { get; set; } = 8192;

#region Start/Stop server

Expand Down
44 changes: 4 additions & 40 deletions source/NetCoreServer/SslSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public SslSession(SslServer server)
{
Id = Guid.NewGuid();
Server = server;
OptionReceiveBufferSize = server.OptionReceiveBufferSize;
OptionSendBufferSize = server.OptionSendBufferSize;
}

/// <summary>
Expand Down Expand Up @@ -57,49 +59,11 @@ public SslSession(SslServer server)
/// <summary>
/// Option: receive buffer size
/// </summary>
public int OptionReceiveBufferSize
{
get => Socket.ReceiveBufferSize;
set => Socket.ReceiveBufferSize = value;
}
public int OptionReceiveBufferSize { get; set; } = 8192;
/// <summary>
/// Option: send buffer size
/// </summary>
public int OptionSendBufferSize
{
get => Socket.SendBufferSize;
set => Socket.SendBufferSize = value;
}
/// <summary>
/// Option: receive timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionReceiveTimeout
{
get => Socket.ReceiveTimeout;
set => Socket.ReceiveTimeout = value;
}
/// <summary>
/// Option: send timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionSendTimeout
{
get => Socket.SendTimeout;
set => Socket.SendTimeout = value;
}
/// <summary>
/// Option: linger state
/// </summary>
public LingerOption OptionLingerState
{
get => Socket.LingerState;
set => Socket.LingerState = value;
}
public int OptionSendBufferSize { get; set; } = 8192;

#region Connect/Disconnect session

Expand Down
42 changes: 2 additions & 40 deletions source/NetCoreServer/TcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,49 +83,11 @@ public TcpClient(IPEndPoint endpoint)
/// <summary>
/// Option: receive buffer size
/// </summary>
public int OptionReceiveBufferSize
{
get => Socket.ReceiveBufferSize;
set => Socket.ReceiveBufferSize = value;
}
public int OptionReceiveBufferSize { get; set; } = 8192;
/// <summary>
/// Option: send buffer size
/// </summary>
public int OptionSendBufferSize
{
get => Socket.SendBufferSize;
set => Socket.SendBufferSize = value;
}
/// <summary>
/// Option: receive timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionReceiveTimeout
{
get => Socket.ReceiveTimeout;
set => Socket.ReceiveTimeout = value;
}
/// <summary>
/// Option: send timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionSendTimeout
{
get => Socket.SendTimeout;
set => Socket.SendTimeout = value;
}
/// <summary>
/// Option: linger state
/// </summary>
public LingerOption OptionLingerState
{
get => Socket.LingerState;
set => Socket.LingerState = value;
}
public int OptionSendBufferSize { get; set; } = 8192;

#region Connect/Disconnect client

Expand Down
8 changes: 8 additions & 0 deletions source/NetCoreServer/TcpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ public TcpServer(IPEndPoint endpoint)
/// This option will enable/disable SO_EXCLUSIVEADDRUSE if the OS support this feature
/// </remarks>
public bool OptionExclusiveAddressUse { get; set; }
/// <summary>
/// Option: receive buffer size
/// </summary>
public int OptionReceiveBufferSize { get; set; } = 8192;
/// <summary>
/// Option: send buffer size
/// </summary>
public int OptionSendBufferSize { get; set; } = 8192;

#region Start/Stop server

Expand Down
44 changes: 4 additions & 40 deletions source/NetCoreServer/TcpSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public TcpSession(TcpServer server)
{
Id = Guid.NewGuid();
Server = server;
OptionReceiveBufferSize = server.OptionReceiveBufferSize;
OptionSendBufferSize = server.OptionSendBufferSize;
}

/// <summary>
Expand Down Expand Up @@ -56,49 +58,11 @@ public TcpSession(TcpServer server)
/// <summary>
/// Option: receive buffer size
/// </summary>
public int OptionReceiveBufferSize
{
get => Socket.ReceiveBufferSize;
set => Socket.ReceiveBufferSize = value;
}
public int OptionReceiveBufferSize { get; set; } = 8192;
/// <summary>
/// Option: send buffer size
/// </summary>
public int OptionSendBufferSize
{
get => Socket.SendBufferSize;
set => Socket.SendBufferSize = value;
}
/// <summary>
/// Option: receive timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionReceiveTimeout
{
get => Socket.ReceiveTimeout;
set => Socket.ReceiveTimeout = value;
}
/// <summary>
/// Option: send timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionSendTimeout
{
get => Socket.SendTimeout;
set => Socket.SendTimeout = value;
}
/// <summary>
/// Option: linger state
/// </summary>
public LingerOption OptionLingerState
{
get => Socket.LingerState;
set => Socket.LingerState = value;
}
public int OptionSendBufferSize { get; set; } = 8192;

#region Connect/Disconnect session

Expand Down
42 changes: 2 additions & 40 deletions source/NetCoreServer/UdpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,49 +94,11 @@ public UdpClient(IPEndPoint endpoint)
/// <summary>
/// Option: receive buffer size
/// </summary>
public int OptionReceiveBufferSize
{
get => Socket.ReceiveBufferSize;
set => Socket.ReceiveBufferSize = value;
}
public int OptionReceiveBufferSize { get; set; } = 8192;
/// <summary>
/// Option: send buffer size
/// </summary>
public int OptionSendBufferSize
{
get => Socket.SendBufferSize;
set => Socket.SendBufferSize = value;
}
/// <summary>
/// Option: receive timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionReceiveTimeout
{
get => Socket.ReceiveTimeout;
set => Socket.ReceiveTimeout = value;
}
/// <summary>
/// Option: send timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionSendTimeout
{
get => Socket.SendTimeout;
set => Socket.SendTimeout = value;
}
/// <summary>
/// Option: linger state
/// </summary>
public LingerOption OptionLingerState
{
get => Socket.LingerState;
set => Socket.LingerState = value;
}
public int OptionSendBufferSize { get; set; } = 8192;

#region Connect/Disconnect client

Expand Down
42 changes: 2 additions & 40 deletions source/NetCoreServer/UdpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,49 +95,11 @@ public UdpServer(IPEndPoint endpoint)
/// <summary>
/// Option: receive buffer size
/// </summary>
public int OptionReceiveBufferSize
{
get => Socket.ReceiveBufferSize;
set => Socket.ReceiveBufferSize = value;
}
public int OptionReceiveBufferSize { get; set; } = 8192;
/// <summary>
/// Option: send buffer size
/// </summary>
public int OptionSendBufferSize
{
get => Socket.SendBufferSize;
set => Socket.SendBufferSize = value;
}
/// <summary>
/// Option: receive timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionReceiveTimeout
{
get => Socket.ReceiveTimeout;
set => Socket.ReceiveTimeout = value;
}
/// <summary>
/// Option: send timeout in milliseconds
/// </summary>
/// <remarks>
/// The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.
/// </remarks>
public int OptionSendTimeout
{
get => Socket.SendTimeout;
set => Socket.SendTimeout = value;
}
/// <summary>
/// Option: linger state
/// </summary>
public LingerOption OptionLingerState
{
get => Socket.LingerState;
set => Socket.LingerState = value;
}
public int OptionSendBufferSize { get; set; } = 8192;

#region Connect/Disconnect client

Expand Down
2 changes: 1 addition & 1 deletion tests/tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit fd4fdc0

Please sign in to comment.