ISteamNetworking
Note
This documentation is auto-generated. Methods marked with 🤖 are automatically generated bindings. Methods marked with ✍️ are manually implemented and methods marked with ✋ are currently not implemented.
Note
This interface can be accessed has multiple accessors (e.g. a GameServer variant), the documentation shows Networking everywhere but it can also be accessed with GameServerNetworking.
List of Functions
List of Callbacks
Function Reference
- Networking.AcceptP2PSessionWithUser(steamIDRemote)
🤖 Auto-generated binding
- Parameters:
steamIDRemote (uint64 - CSteamID) –
- Returns:
(bool) Return value
- SteamWorks:
Example:
function Steam.Networking.OnP2PSessionRequest(data)
-- Accept connection from known players only
if isKnownPlayer(data.m_steamIDRemote) then
Steam.Networking.AcceptP2PSessionWithUser(data.m_steamIDRemote)
end
end
- Networking.AllowP2PPacketRelay(bAllow)
🤖 Auto-generated binding
- Parameters:
bAllow (bool) –
- Returns:
(bool) Return value
- SteamWorks:
Example:
Steam.Networking.AllowP2PPacketRelay(true)
- Networking.CloseP2PChannelWithUser(steamIDRemote, nChannel)
🤖 Auto-generated binding
- Parameters:
steamIDRemote (uint64 - CSteamID) –
nChannel (int) –
- Returns:
(bool) Return value
- SteamWorks:
- Networking.CloseP2PSessionWithUser(steamIDRemote)
🤖 Auto-generated binding
- Parameters:
steamIDRemote (uint64 - CSteamID) –
- Returns:
(bool) Return value
- SteamWorks:
Example:
-- Clean up when a player leaves
Steam.Networking.CloseP2PSessionWithUser(playerSteamID)
- Networking.CreateConnectionSocket(nIP, nPort, nTimeoutSec)
🤖 Auto-generated binding
- Parameters:
nIP – (SteamIPAddress_t)
nPort (int) –
nTimeoutSec (int) –
- Returns:
(int - SNetSocket_t) Return value
- SteamWorks:
- Networking.CreateListenSocket(nVirtualP2PPort, nIP, nPort, bAllowUseOfPacketRelay)
🤖 Auto-generated binding
- Parameters:
nVirtualP2PPort (int) –
nIP – (SteamIPAddress_t)
nPort (int) –
bAllowUseOfPacketRelay (bool) –
- Returns:
(int - SNetListenSocket_t) Return value
- SteamWorks:
- Networking.CreateP2PConnectionSocket(steamIDTarget, nVirtualPort, nTimeoutSec, bAllowUseOfPacketRelay)
🤖 Auto-generated binding
- Parameters:
steamIDTarget (uint64 - CSteamID) –
nVirtualPort (int) –
nTimeoutSec (int) –
bAllowUseOfPacketRelay (bool) –
- Returns:
(int - SNetSocket_t) Return value
- SteamWorks:
- Networking.DestroyListenSocket(hSocket, bNotifyRemoteEnd)
🤖 Auto-generated binding
- Parameters:
hSocket (int - SNetListenSocket_t) –
bNotifyRemoteEnd (bool) –
- Returns:
(bool) Return value
- SteamWorks:
- Networking.DestroySocket(hSocket, bNotifyRemoteEnd)
🤖 Auto-generated binding
- Parameters:
hSocket (int - SNetSocket_t) –
bNotifyRemoteEnd (bool) –
- Returns:
(bool) Return value
- SteamWorks:
- Networking.GetListenSocketInfo(hListenSocket)
🤖 Auto-generated binding
- Parameters:
hListenSocket (int - SNetListenSocket_t) –
- Returns:
(bool) Return value
- Returns:
(SteamIPAddress_t)
pnIP- Returns:
(int)
pnPort- SteamWorks:
Signature differences from C++ API:
Parameter
pnIPis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
pnPortis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- Networking.GetMaxPacketSize(hSocket)
🤖 Auto-generated binding
- Parameters:
hSocket (int - SNetSocket_t) –
- Returns:
(int) Return value
- SteamWorks:
- Networking.GetP2PSessionState(steamIDRemote)
🤖 Auto-generated binding
- Parameters:
steamIDRemote (uint64 - CSteamID) –
- Returns:
(bool) Return value
- Returns:
(P2PSessionState_t)
pConnectionState- SteamWorks:
Signature differences from C++ API:
Parameter
pConnectionStateis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
Example:
local ok, state = Steam.Networking.GetP2PSessionState(playerSteamID)
if ok then
print('Connecting:', state.m_bConnecting ~= 0)
print('Connected:', state.m_bConnectionActive ~= 0)
end
- Networking.GetSocketConnectionType(hSocket)
🤖 Auto-generated binding
- Parameters:
hSocket (int - SNetSocket_t) –
- Returns:
(int - ESNetSocketConnectionType) Return value
- SteamWorks:
- Networking.GetSocketInfo(hSocket)
🤖 Auto-generated binding
- Parameters:
hSocket (int - SNetSocket_t) –
- Returns:
(bool) Return value
- Returns:
(uint64)
pSteamIDRemote- Returns:
(int)
peSocketStatus- Returns:
(SteamIPAddress_t)
punIPRemote- Returns:
(int)
punPortRemote- SteamWorks:
Signature differences from C++ API:
Parameter
pSteamIDRemoteis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
peSocketStatusis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
punIPRemoteis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
punPortRemoteis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- Networking.IsDataAvailable(hListenSocket)
🤖 Auto-generated binding
- Parameters:
hListenSocket (int - SNetListenSocket_t) –
- Returns:
(bool) Return value
- Returns:
(int)
pcubMsgSize- Returns:
(int)
phSocket- SteamWorks:
Signature differences from C++ API:
Parameter
pcubMsgSizeis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
phSocketis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- Networking.IsDataAvailableOnSocket(hSocket)
🤖 Auto-generated binding
- Parameters:
hSocket (int - SNetSocket_t) –
- Returns:
(bool) Return value
- Returns:
(int)
pcubMsgSize- SteamWorks:
Signature differences from C++ API:
Parameter
pcubMsgSizeis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- Networking.IsP2PPacketAvailable(nChannel)
🤖 Auto-generated binding
- Parameters:
nChannel (int) –
- Returns:
(bool) Return value
- Returns:
(int)
pcubMsgSize- SteamWorks:
Signature differences from C++ API:
Parameter
pcubMsgSizeis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
Example:
while Steam.Networking.IsP2PPacketAvailable(0) do
local data, senderID = Steam.Networking.ReadP2PPacket(4096, 0)
if data then
handlePacket(senderID, data)
end
end
- Networking.ReadP2PPacket(cubDest, nChannel)
🤖 Auto-generated binding
- Parameters:
cubDest (int?) – size of the buffer to allocate for
pubDest. Ifnilthen the buffer will beNULL.nChannel (int) –
- Returns:
(bool) Return value
- Returns:
(str)
pubDest- Returns:
(int)
pcubMsgSize- Returns:
(uint64)
psteamIDRemote- SteamWorks:
Signature differences from C++ API:
Parameter
pubDestis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
pcubMsgSizeis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
psteamIDRemoteis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
Notes:
See
Networking.IsP2PPacketAvailable()’s example.
- Networking.RetrieveData(hListenSocket, cubDest)
🤖 Auto-generated binding
- Parameters:
hListenSocket (int - SNetListenSocket_t) –
cubDest (int?) – size of the buffer to allocate for
pubDest. Ifnilthen the buffer will beNULL.
- Returns:
(bool) Return value
- Returns:
(str)
pubDest- Returns:
(int)
pcubMsgSize- Returns:
(int)
phSocket- SteamWorks:
Signature differences from C++ API:
Parameter
pubDestis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
pcubMsgSizeis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
phSocketis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- Networking.RetrieveDataFromSocket(hSocket, cubDest)
🤖 Auto-generated binding
- Parameters:
hSocket (int - SNetSocket_t) –
cubDest (int?) – size of the buffer to allocate for
pubDest. Ifnilthen the buffer will beNULL.
- Returns:
(bool) Return value
- Returns:
(str)
pubDest- Returns:
(int)
pcubMsgSize- SteamWorks:
Signature differences from C++ API:
Parameter
pubDestis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
pcubMsgSizeis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- Networking.SendDataOnSocket(hSocket, pubData, cubData, bReliable)
🤖 Auto-generated binding
- Parameters:
hSocket (int - SNetSocket_t) –
pubData (str?) –
cubData (int) – size of the input array
pubDatabReliable (bool) –
- Returns:
(bool) Return value
- SteamWorks:
- Networking.SendP2PPacket(steamIDRemote, pubData, cubData, eP2PSendType, nChannel)
🤖 Auto-generated binding
- Parameters:
steamIDRemote (uint64 - CSteamID) –
pubData (str?) –
cubData (int) – size of the input array
pubDataeP2PSendType (int - EP2PSend) –
nChannel (int) –
- Returns:
(bool) Return value
- SteamWorks:
Example:
local data = serializeGamePacket(packet)
Steam.Networking.SendP2PPacket(targetSteamID, data, #data, 'Reliable', 0)
Callbacks
- Networking.OnP2PSessionRequest()
Callback for P2PSessionRequest_t
callback(data) receives:
data.m_steamIDRemote (uint64 - CSteamID)
- Networking.OnP2PSessionConnectFail()
Callback for P2PSessionConnectFail_t
callback(data) receives:
data.m_steamIDRemote (uint64 - CSteamID)
data.m_eP2PSessionError (int)
Example:
function Steam.Networking.OnP2PSessionConnectFail(data)
print('P2P connection failed with', tostring(data.m_steamIDRemote),
'error:', data.m_eP2PSessionError)
end
- Networking.OnSocketStatusCallback()
Callback for SocketStatusCallback_t
callback(data) receives:
data.m_hSocket (int - SNetSocket_t)
data.m_hListenSocket (int - SNetListenSocket_t)
data.m_steamIDRemote (uint64 - CSteamID)
data.m_eSNetSocketState (int)