Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing SendBufferSize for sockets #441

Open
IvMisticos opened this issue Aug 21, 2021 · 12 comments
Open

Changing SendBufferSize for sockets #441

IvMisticos opened this issue Aug 21, 2021 · 12 comments

Comments

@IvMisticos
Copy link

IvMisticos commented Aug 21, 2021

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.

@IvMisticos
Copy link
Author

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?

@IvMisticos
Copy link
Author

IvMisticos commented Aug 24, 2021

GetConfigValue confirms that it is not set globally, at least not to the right value.

@IvMisticos
Copy link
Author

@rlabrecque any clue? I've tried allocating memory with Marshal.AllocHGlobal and setting it to my value but that still hasn't worked.

@IvMisticos
Copy link
Author

IvMisticos commented Aug 29, 2021

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.

@IvMisticos
Copy link
Author

IvMisticos commented Aug 31, 2021

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

@rlabrecque
Copy link
Owner

rlabrecque commented Sep 1, 2021

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

@IvMisticos
Copy link
Author

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?

@IvMisticos
Copy link
Author

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?

rlabrecque added a commit that referenced this issue Sep 12, 2021
Fix ISteamNetworkingUtils_GetConfigValue parameter from out -> ref (#441)
@IvMisticos
Copy link
Author

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.

@IvMisticos
Copy link
Author

IvMisticos commented Sep 12, 2021

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.

@IvMisticos
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants