NetCoreServer
NetCoreServer copied to clipboard
Where is the right place to config socket buffer size
When ssl session was created, It will have 3 buffer, which size are 65k. Where should I change the default size? Thank you.
You can use OptionReceiveBufferSize
and OptionSendBufferSize
options in Client/Session for your case:
// Prepare receive & send buffers
_receiveBuffer.Reserve(OptionReceiveBufferSize);
_sendBufferMain.Reserve(OptionSendBufferSize);
_sendBufferFlush.Reserve(OptionSendBufferSize);
I'v seen this code. but the problem is, these value are using Socket.ReceiveBufferSize and Socket.SendBufferSize, when SslSession is created, the Socket object is not there. The socket was given in Connect method, in the same method, buffer Reserved. There is no chance to set OptionReceiveBufferSize before Buffer.Reserve was called.
public int OptionReceiveBufferSize
{
get => Socket.ReceiveBufferSize;
set => Socket.ReceiveBufferSize = value;
}
.....
.....
internal void Connect(Socket socket)
{
Socket = socket;
// Update the session socket disposed flag
IsSocketDisposed = false;
// Setup buffers
_receiveBuffer = new Buffer();
_sendBufferMain = new Buffer();
_sendBufferFlush = new Buffer();
// Apply the option: keep alive
if (Server.OptionKeepAlive)
Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
// Apply the option: no delay
if (Server.OptionNoDelay)
Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, true);
// Prepare receive & send buffers
_receiveBuffer.Reserve(OptionReceiveBufferSize);
_sendBufferMain.Reserve(OptionSendBufferSize);
_sendBufferFlush.Reserve(OptionSendBufferSize);
aah ok, I understand the issue. Will fix it soon!