Sorry for delay here.
beacon code does have that 5 sec delay, but I never intended that to be fixed. You are free to adjust that as you please and it is exposed in ini system as you’ve found out.
From Valve’s site, I would suggest 20 seconds at least
Error handling
SendP2PPacket() will try for up to 20 seconds to establish a connection to remote user and deliver packet. Your first sends may be delayed by that long. If there is an error establishing connection, a callback will be posted:
As for second problem, which assert are you hitting? Is it one in NotifyControlMessage()?
I’m not sure if larger delay would allow for proper clean up and guarantee no stray packet from potential host. That being said, I’m looking through Steam P2P docs because I swear that, unlike udp/tcp, SteamChannel is reciprocal. Valve’s single page on p2p doesn’t even mention channel. header says this
nChannel is a routing number you can use to help route message to different systems - you'll have to call ReadP2PPacket() with same channel number in order to retrieve data on other end using different channels to talk to same user will still use same underlying p2p connection, saving on resources
I don’t think you can set client to “any port” and send to proper host port. If SteamChannels don’t match I think communication would fail. It’s been a little while, but I wonder if something like asymmetry would have prevent issue. Maybe some kind of “client offset” would allow this (send to host port XXX, return data on client port XXX + constant).
underlying issue is that beacons are attempting to use same code as regular networking, so socket isn’t aware of nature of data to reject something like stray packets.
It may also be an issue with DeadConnections array I have internally to Steam socket cleanup. I move old p2p connections to this array for a time period to prevent stray data and reconnections when I know I want socket dead. But it is only 3 seconds. You may want to investigate that at time of stray packet. You would find that Steam socket subsystem is getting a AcceptP2PConnection call after you’ve disconnected. I would expect it to be rejected.
If you don’t mind doing a little more digging and report back I can try to help further.