Steamworks.NET
Steamworks.NET copied to clipboard
Changing SendBufferSize for sockets
SEE LAST COMMENT
I am trying to set SendBufferSize for my Steam networking sockets in two ways. First would be global options and second the parameters you pass to CreateListenSocketIP:
unsafe
{
var sendBufferSize = 1024 * 1024;
SteamGameServerNetworkingUtils.SetConfigValue(
ESteamNetworkingConfigValue.k_ESteamNetworkingConfig_SendBufferSize,
ESteamNetworkingConfigScope.k_ESteamNetworkingConfig_Global, IntPtr.Zero,
ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32, new IntPtr(&sendBufferSize));
}
var options = new[]
{
new SteamNetworkingConfigValue_t
{
m_eValue = ESteamNetworkingConfigValue.k_ESteamNetworkingConfig_SendBufferSize,
m_eDataType = ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32,
m_val = new SteamNetworkingConfigValue_t.OptionValue
{
m_int32 = 1024 * 1024
}
}
};
SteamGameServerNetworkingSockets.CreateListenSocketIP(ref address, options.Length, options);
But neither of the config helpers seem to work for me - the limit stays the default (512 * 1024). How may I debug the issue and could it be my values being GCed or something to do with pointers? Not sure.
Offtopic: when do we get a new release to include all the fixes and such that have been merged since May? Possibly an automated nightly build even?
GetConfigValue confirms that it is not set globally, at least not to the right value.
@rlabrecque any clue? I've tried allocating memory with Marshal.AllocHGlobal and setting it to my value but that still hasn't worked.
GetConfigValue is invalid. According to docs: https://partner.steamgames.com/doc/api/ISteamNetworkingUtils#GetConfigValue
ESteamNetworkingGetConfigValueResult GetConfigValue(
ESteamNetworkingConfigValue eValue,
ESteamNetworkingConfigScope eScopeType,
intptr_t scopeObj,
ESteamNetworkingConfigDataType *pOutDataType,
void *pResult,
size_t *cbResult);
cbResult: IN: the size of your buffer. OUT: the number of bytes filled in or required
Which means cbResult should be ref instead of out as you have it. After changing it to be this way, it returned a correct value.
Please do fix it ❤️ would love to see a new release as well with all pending changes, or possibly nightly versions on commit.
There's still some issue though likely, because I am setting the value, when I use GetConfigValue it is correct (~1 MB), but when I try to connect and send data it says that:
src/steamnetworkingsockets/clientlib/steamnetworkingsockets_connections.cpp (1915) : Assertion Failed: Message size 732253 is too big. Max is 524288
Hey there, I haven't had a chance to look more indepth and honestly it might be a few weeks still, I suspect there's something weird going on here:
new IntPtr(&sendBufferSize) and m_val = new SteamNetworkingConfigValue_t.OptionValue
We'll probably need something like this around here: https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.structuretoptr?view=net-5.0
Hey, thank you for taking a look. On the other side, with fixed Get method I managed to set it (and get returns the right value), but Steam still shows the message above. Do you think Steam could be reading the value wrong due to what you've mentioned?
Interesting how with new Get method it all is set properly for connection, socket and global. BUT I am still getting this:
src/steamnetworkingsockets/clientlib/steamnetworkingsockets_connections.cpp (1915) : Assertion Failed: Message size 732253 is too big. Max is 524288
How is this possible if max is definitely configured to be higher than that and Get methods return valid proper values I use?
Hmm are you still setting the options? I wonder if that's overriding the Set at all?
This /may/ help too, but I haven't dugg in deeper yet
https://github.com/ValveSoftware/GameNetworkingSockets/blob/42d26cf93f3ea415777170625ac20ad279cef1a3/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp#L984
https://github.com/ValveSoftware/GameNetworkingSockets/blob/42d26cf93f3ea415777170625ac20ad279cef1a3/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp#L2044
https://github.com/ValveSoftware/GameNetworkingSockets/blob/42d26cf93f3ea415777170625ac20ad279cef1a3/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp#L2100
Using an empty array for options atm, it returns OKInherited and the right value for connection. Could try options if you think that would change anything.
Tested options array, just using an array does change the listener options so now it returns OK instead of OKInherited and a value I've provided.
Steam support have responded to me:
The max message size is a separate value from the send buffer size, and is not configurable. The value is k_cbMaxSteamNetworkingSocketsMessageSizeSend.
If you need to send very big messages, you'll need to chop them up into pieces and reassemble them.