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:

AcceptP2PSessionWithUser

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:

AllowP2PPacketRelay

Example:

Steam.Networking.AllowP2PPacketRelay(true)
Networking.CloseP2PChannelWithUser(steamIDRemote, nChannel)

🤖 Auto-generated binding

Parameters:
  • steamIDRemote (uint64 - CSteamID) –

  • nChannel (int) –

Returns:

(bool) Return value

SteamWorks:

CloseP2PChannelWithUser

Networking.CloseP2PSessionWithUser(steamIDRemote)

🤖 Auto-generated binding

Parameters:

steamIDRemote (uint64 - CSteamID) –

Returns:

(bool) Return value

SteamWorks:

CloseP2PSessionWithUser

Example:

-- Clean up when a player leaves
Steam.Networking.CloseP2PSessionWithUser(playerSteamID)
Networking.CreateConnectionSocket(nIP, nPort, nTimeoutSec)

🤖 Auto-generated binding

Parameters:
Returns:

(int - SNetSocket_t) Return value

SteamWorks:

CreateConnectionSocket

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:

CreateListenSocket

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:

CreateP2PConnectionSocket

Networking.DestroyListenSocket(hSocket, bNotifyRemoteEnd)

🤖 Auto-generated binding

Parameters:
  • hSocket (int - SNetListenSocket_t) –

  • bNotifyRemoteEnd (bool) –

Returns:

(bool) Return value

SteamWorks:

DestroyListenSocket

Networking.DestroySocket(hSocket, bNotifyRemoteEnd)

🤖 Auto-generated binding

Parameters:
  • hSocket (int - SNetSocket_t) –

  • bNotifyRemoteEnd (bool) –

Returns:

(bool) Return value

SteamWorks:

DestroySocket

Networking.GetListenSocketInfo(hListenSocket)

🤖 Auto-generated binding

Parameters:

hListenSocket (int - SNetListenSocket_t) –

Returns:

(bool) Return value

Returns:

(SteamIPAddress_t) pnIP

Returns:

(int) pnPort

SteamWorks:

GetListenSocketInfo

Signature differences from C++ API:

  • Parameter pnIP is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

  • Parameter pnPort is 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:

GetMaxPacketSize

Networking.GetP2PSessionState(steamIDRemote)

🤖 Auto-generated binding

Parameters:

steamIDRemote (uint64 - CSteamID) –

Returns:

(bool) Return value

Returns:

(P2PSessionState_t) pConnectionState

SteamWorks:

GetP2PSessionState

Signature differences from C++ API:

  • Parameter pConnectionState is 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:

GetSocketConnectionType

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:

GetSocketInfo

Signature differences from C++ API:

  • Parameter pSteamIDRemote is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

  • Parameter peSocketStatus is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

  • Parameter punIPRemote is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

  • Parameter punPortRemote is 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:

IsDataAvailable

Signature differences from C++ API:

  • Parameter pcubMsgSize is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

  • Parameter phSocket is 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:

IsDataAvailableOnSocket

Signature differences from C++ API:

  • Parameter pcubMsgSize is 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:

IsP2PPacketAvailable

Signature differences from C++ API:

  • Parameter pcubMsgSize is 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. If nil then the buffer will be NULL.

  • nChannel (int) –

Returns:

(bool) Return value

Returns:

(str) pubDest

Returns:

(int) pcubMsgSize

Returns:

(uint64) psteamIDRemote

SteamWorks:

ReadP2PPacket

Signature differences from C++ API:

  • Parameter pubDest is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

  • Parameter pcubMsgSize is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

  • Parameter psteamIDRemote is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

Notes:

Networking.RetrieveData(hListenSocket, cubDest)

🤖 Auto-generated binding

Parameters:
  • hListenSocket (int - SNetListenSocket_t) –

  • cubDest (int?) – size of the buffer to allocate for pubDest. If nil then the buffer will be NULL.

Returns:

(bool) Return value

Returns:

(str) pubDest

Returns:

(int) pcubMsgSize

Returns:

(int) phSocket

SteamWorks:

RetrieveData

Signature differences from C++ API:

  • Parameter pubDest is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

  • Parameter pcubMsgSize is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

  • Parameter phSocket is 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. If nil then the buffer will be NULL.

Returns:

(bool) Return value

Returns:

(str) pubDest

Returns:

(int) pcubMsgSize

SteamWorks:

RetrieveDataFromSocket

Signature differences from C++ API:

  • Parameter pubDest is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.

  • Parameter pcubMsgSize is 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 pubData

  • bReliable (bool) –

Returns:

(bool) Return value

SteamWorks:

SendDataOnSocket

Networking.SendP2PPacket(steamIDRemote, pubData, cubData, eP2PSendType, nChannel)

🤖 Auto-generated binding

Parameters:
  • steamIDRemote (uint64 - CSteamID) –

  • pubData (str?) –

  • cubData (int) – size of the input array pubData

  • eP2PSendType (int - EP2PSend) –

  • nChannel (int) –

Returns:

(bool) Return value

SteamWorks:

SendP2PPacket

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)