ISteamNetworkingSockets
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 NetworkingSockets_SteamAPI everywhere but it can also be accessed with GameServerNetworkingSockets_SteamAPI.
Note
For a complete client/server walkthrough, see Networking Sockets Example.
List of Functions
List of Callbacks
Function Reference
- NetworkingSockets.AcceptConnection(hConn)
🤖 Auto-generated binding
- Parameters:
hConn (int - HSteamNetConnection) –
- Returns:
(int - EResult) Return value
- SteamWorks:
Example:
local result = Steam.NetworkingSockets.AcceptConnection(hConn)
if result ~= Steam.k_EResultOK then
print('Failed to accept connection:', result)
end
- NetworkingSockets.BeginAsyncRequestFakeIP(nNumPorts)
🤖 Auto-generated binding
- Parameters:
nNumPorts (int) –
- Returns:
(bool) Return value
- SteamWorks:
- NetworkingSockets.CloseConnection(hPeer, nReason, pszDebug, bEnableLinger)
🤖 Auto-generated binding
- Parameters:
hPeer (int - HSteamNetConnection) –
nReason (int) –
pszDebug (str?) –
bEnableLinger (bool) –
- Returns:
(bool) Return value
- SteamWorks:
Example:
Steam.NetworkingSockets.CloseConnection(hConn, 0, 'Player left', false)
- NetworkingSockets.CloseListenSocket(hSocket)
🤖 Auto-generated binding
- Parameters:
hSocket (int - HSteamListenSocket) –
- Returns:
(bool) Return value
- SteamWorks:
Example:
Steam.NetworkingSockets.CloseListenSocket(hListenSocket)
- NetworkingSockets.ConfigureConnectionLanes(hConn, nNumLanes, pLanePriorities, pLaneWeights)
🤖 Auto-generated binding
- Parameters:
hConn (int - HSteamNetConnection) –
nNumLanes (int) – size of the input arrays
pLanePrioritiesandpLaneWeightspLanePriorities (int[]?) –
pLaneWeights (int[]?) –
- Returns:
(int - EResult) Return value
- SteamWorks:
- NetworkingSockets.ConnectByIPAddress(address, nOptions, pOptions)
🤖 Auto-generated binding
- Parameters:
address – (SteamNetworkingIPAddr)
nOptions (int) – size of the input array
pOptionspOptions – (SteamNetworkingConfigValue_t[]?)
- Returns:
(int - HSteamNetConnection) Return value
- SteamWorks:
Example:
local addr = Steam.newSteamNetworkingIPAddr {}
addr:ParseString("192.168.1.100:27015")
local hConn = Steam.NetworkingSockets.ConnectByIPAddress(addr, 0, nil)
- NetworkingSockets.ConnectP2P(identityRemote, nRemoteVirtualPort, nOptions, pOptions)
🤖 Auto-generated binding
- Parameters:
identityRemote – (SteamNetworkingIdentity)
nRemoteVirtualPort (int) –
nOptions (int) – size of the input array
pOptionspOptions – (SteamNetworkingConfigValue_t[]?)
- Returns:
(int - HSteamNetConnection) Return value
- SteamWorks:
Example:
-- Connect to another player using their Steam identity
local id = Steam.newSteamNetworkingIdentity {}
id:SetSteamID(friendSteamID)
local hConn = Steam.NetworkingSockets.ConnectP2P(id, 0, 0, nil)
- NetworkingSockets.ConnectToHostedDedicatedServer(identityTarget, nRemoteVirtualPort, nOptions, pOptions)
🤖 Auto-generated binding
- Parameters:
identityTarget – (SteamNetworkingIdentity)
nRemoteVirtualPort (int) –
nOptions (int) – size of the input array
pOptionspOptions – (SteamNetworkingConfigValue_t[]?)
- Returns:
(int - HSteamNetConnection) Return value
- SteamWorks:
- NetworkingSockets.CreateHostedDedicatedServerListenSocket(nLocalVirtualPort, nOptions, pOptions)
🤖 Auto-generated binding
- Parameters:
nLocalVirtualPort (int) –
nOptions (int) – size of the input array
pOptionspOptions – (SteamNetworkingConfigValue_t[]?)
- Returns:
(int - HSteamListenSocket) Return value
- SteamWorks:
- NetworkingSockets.CreateListenSocketIP(localAddress, nOptions, pOptions)
🤖 Auto-generated binding
- Parameters:
localAddress – (SteamNetworkingIPAddr)
nOptions (int) – size of the input array
pOptionspOptions – (SteamNetworkingConfigValue_t[]?)
- Returns:
(int - HSteamListenSocket) Return value
- SteamWorks:
Example:
-- Listen on all interfaces, port 27015
local addr = Steam.newSteamNetworkingIPAddr {}
addr:SetIPv6LocalHost(27015)
local hSocket = Steam.NetworkingSockets.CreateListenSocketIP(addr, 0, nil)
- NetworkingSockets.CreateListenSocketP2P(nLocalVirtualPort, nOptions, pOptions)
🤖 Auto-generated binding
- Parameters:
nLocalVirtualPort (int) –
nOptions (int) – size of the input array
pOptionspOptions – (SteamNetworkingConfigValue_t[]?)
- Returns:
(int - HSteamListenSocket) Return value
- SteamWorks:
Example:
-- Create a P2P listen socket on virtual port 0
local hSocket = Steam.NetworkingSockets.CreateListenSocketP2P(0, 0, nil)
- NetworkingSockets.CreateListenSocketP2PFakeIP(idxFakePort, nOptions, pOptions)
🤖 Auto-generated binding
- Parameters:
idxFakePort (int) –
nOptions (int) – size of the input array
pOptionspOptions – (SteamNetworkingConfigValue_t[]?)
- Returns:
(int - HSteamListenSocket) Return value
- SteamWorks:
- NetworkingSockets.CreatePollGroup()
🤖 Auto-generated binding
- Returns:
(int - HSteamNetPollGroup) Return value
- SteamWorks:
Example:
local hPollGroup = Steam.NetworkingSockets.CreatePollGroup()
-- Add connections to the poll group
Steam.NetworkingSockets.SetConnectionPollGroup(hConn, hPollGroup)
- NetworkingSockets.CreateSocketPair(bUseNetworkLoopback, pIdentity1, pIdentity2)
🤖 Auto-generated binding
- Parameters:
bUseNetworkLoopback (bool) –
pIdentity1 – (SteamNetworkingIdentity)
pIdentity2 – (SteamNetworkingIdentity)
- Returns:
(bool) Return value
- Returns:
(int)
pOutConnection1- Returns:
(int)
pOutConnection2- SteamWorks:
Signature differences from C++ API:
Parameter
pOutConnection1is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
pOutConnection2is not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- NetworkingSockets.DestroyPollGroup(hPollGroup)
🤖 Auto-generated binding
- Parameters:
hPollGroup (int - HSteamNetPollGroup) –
- Returns:
(bool) Return value
- SteamWorks:
Example:
Steam.NetworkingSockets.DestroyPollGroup(hPollGroup)
- NetworkingSockets.FlushMessagesOnConnection(hConn)
🤖 Auto-generated binding
- Parameters:
hConn (int - HSteamNetConnection) –
- Returns:
(int - EResult) Return value
- SteamWorks:
Example:
Steam.NetworkingSockets.FlushMessagesOnConnection(hConn)
- NetworkingSockets.GetAuthenticationStatus()
🤖 Auto-generated binding
- Returns:
(int - ESteamNetworkingAvailability) Return value
- Returns:
(SteamNetAuthenticationStatus_t)
pDetails- SteamWorks:
Signature differences from C++ API:
Parameter
pDetailsis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- NetworkingSockets.GetConnectionInfo(hConn)
🤖 Auto-generated binding
- Parameters:
hConn (int - HSteamNetConnection) –
- Returns:
(bool) Return value
- Returns:
(SteamNetConnectionInfo_t)
pInfo- SteamWorks:
Signature differences from C++ API:
Parameter
pInfois not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
Example:
local ok, info = Steam.NetworkingSockets.GetConnectionInfo(hConn)
if ok then
print('Connection state:', info.m_eState)
end
- NetworkingSockets.GetConnectionName(hPeer, nMaxLen)
🤖 Auto-generated binding
- Parameters:
hPeer (int - HSteamNetConnection) –
nMaxLen (int?) – size of the buffer to allocate for
pszName. Ifnilthen the buffer will beNULL.
- Returns:
(bool) Return value
- Returns:
(str)
pszName- SteamWorks:
Signature differences from C++ API:
Parameter
pszNameis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- NetworkingSockets.GetConnectionRealTimeStatus(hConn, nLanes)
🤖 Auto-generated binding
- Parameters:
hConn (int - HSteamNetConnection) –
nLanes (int) –
- Returns:
(int - EResult) Return value
- Returns:
(SteamNetConnectionRealTimeStatus_t)
pStatus- Returns:
- SteamWorks:
Signature differences from C++ API:
Parameter
pStatusis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.Parameter
pLanesis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- NetworkingSockets.GetConnectionUserData(hPeer)
🤖 Auto-generated binding
- Parameters:
hPeer (int - HSteamNetConnection) –
- Returns:
(uint64) Return value
- SteamWorks:
Example:
local playerIndex = Steam.NetworkingSockets.GetConnectionUserData(hConn)
- NetworkingSockets.GetDetailedConnectionStatus(hConn, cbBuf)
🤖 Auto-generated binding
- Parameters:
hConn (int - HSteamNetConnection) –
cbBuf (int?) – size of the buffer to allocate for
pszBuf. Ifnilthen the buffer will beNULL.
- Returns:
(int) Return value
- Returns:
(str)
pszBuf- SteamWorks:
Signature differences from C++ API:
Parameter
pszBufis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- NetworkingSockets.GetFakeIP(idxFirstPort)
🤖 Auto-generated binding
- Parameters:
idxFirstPort (int) –
- Returns:
(SteamNetworkingFakeIPResult_t)
pInfo- SteamWorks:
Signature differences from C++ API:
Parameter
pInfois not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- NetworkingSockets.GetHostedDedicatedServerPOPID()
🤖 Auto-generated binding
- Returns:
(int - SteamNetworkingPOPID) Return value
- SteamWorks:
- NetworkingSockets.GetHostedDedicatedServerPort()
🤖 Auto-generated binding
- Returns:
(int) Return value
- SteamWorks:
- NetworkingSockets.GetIdentity()
🤖 Auto-generated binding
- Returns:
(bool) Return value
- Returns:
(SteamNetworkingIdentity)
pIdentity- SteamWorks:
Signature differences from C++ API:
Parameter
pIdentityis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
Example:
local ok, identity = Steam.NetworkingSockets.GetIdentity()
if ok then
print('Local identity:', identity)
end
- NetworkingSockets.GetListenSocketAddress(hSocket)
🤖 Auto-generated binding
- Parameters:
hSocket (int - HSteamListenSocket) –
- Returns:
(bool) Return value
- Returns:
(SteamNetworkingIPAddr)
address- SteamWorks:
Signature differences from C++ API:
Parameter
addressis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- NetworkingSockets.GetRemoteFakeIPForConnection(hConn)
🤖 Auto-generated binding
- Parameters:
hConn (int - HSteamNetConnection) –
- Returns:
(int - EResult) Return value
- Returns:
(SteamNetworkingIPAddr)
pOutAddr- SteamWorks:
Signature differences from C++ API:
Parameter
pOutAddris not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
- NetworkingSockets.InitAuthentication()
🤖 Auto-generated binding
- Returns:
(int - ESteamNetworkingAvailability) Return value
- SteamWorks:
Example:
local status = Steam.NetworkingSockets.InitAuthentication()
print('Auth init status:', status)
- NetworkingSockets.ReceiveMessagesOnConnection(hConn, nMaxMessages)
✍️ Manually implemented
- Parameters:
hConn (int) – Connection handle.
nMaxMessages (int) – size of the buffer to allocate for
ppOutMessages
- Returns:
(int) Number of messages received, or -1 if the handle is invalid.
- Returns:
(SteamNetworkingMessage_t[]) Table of received messages,
ppOutMessages. Remember to callReleaseon all of them after using.- SteamWorks:
Receives messages that have been sent to a connection.
Signature differences from C++ API:
Parameter
ppOutMessagesis not a parameter in Lua — it is an output-only array in C++ and is returned as a second return value.
Example:
local count, msgs = Steam.NetworkingSockets.ReceiveMessagesOnConnection(hConn, 32)
for i = 1, count do
local msg = msgs[i]
processMessage(msg.m_pData, msg.m_cbSize)
msg:Release()
end
- NetworkingSockets.ReceiveMessagesOnPollGroup(hPollGroup, nMaxMessages)
✍️ Manually implemented
- Parameters:
hPollGroup (int) – Poll group handle.
nMaxMessages (int) – size of the buffer to allocate for
ppOutMessages
- Returns:
(int) Number of messages received, or -1 if the handle is invalid.
- Returns:
(SteamNetworkingMessage_t[]) Table of received messages,
ppOutMessages. Remember to callReleaseon all of them after using.- SteamWorks:
Receives messages that have arrived on any connection in a poll group.
Signature differences from C++ API:
Parameter
ppOutMessagesis not a parameter in Lua — it is an output-only array in C++ and is returned as a second return value.
Example:
local count, msgs = Steam.NetworkingSockets.ReceiveMessagesOnPollGroup(hPollGroup, 64)
for i = 1, count do
local msg = msgs[i]
handleMessage(msg.m_conn, msg.m_pData, msg.m_cbSize)
msg:Release()
end
- NetworkingSockets.ResetIdentity(pIdentity)
🤖 Auto-generated binding
- Parameters:
pIdentity – (SteamNetworkingIdentity)
- SteamWorks:
- NetworkingSockets.RunCallbacks()
🤖 Auto-generated binding
- SteamWorks:
- NetworkingSockets.SendMessageToConnection(hConn, pData, cbData, nSendFlags)
🤖 Auto-generated binding
- Parameters:
hConn (int - HSteamNetConnection) –
pData (str?) –
cbData (int) – size of the input array
pDatanSendFlags (int) –
- Returns:
(int - EResult) Return value
- Returns:
(uint64)
pOutMessageNumber- SteamWorks:
Signature differences from C++ API:
Parameter
pOutMessageNumberis not a parameter in Lua — it is an output-only pointer in C++ and is returned as an additional return value.
Example:
local data = serializePacket(packet)
local result = Steam.NetworkingSockets.SendMessageToConnection(
hConn, data, #data, Steam.k_nSteamNetworkingSend_Reliable)
if result < 0 then
print('Send failed:', result)
end
- NetworkingSockets.SendMessages(nMessages, pMessages)
✍️ Manually implemented
- Parameters:
nMessages (int) – size of the array
pMessagespMessages (SteamNetworkingMessage_t[]) – array of SteamNetworkingMessage_t userdata objects to send.
- Returns:
(int[]) array of per-message results: positive = message number assigned, negative = EResult error code.
- SteamWorks:
Sends one or more messages to one or more connections in a single call.
Signature differences from C++ API:
Parameter
pOutMessageNumberOrResultis not a parameter in Lua — it is an output-only array in C++ and is returned as the only return value.
Example:
local msg = Steam.NetworkingUtils.AllocateMessage(#payload)
msg.m_conn = hConn
msg.m_nFlags = Steam.k_nSteamNetworkingSend_Reliable
msg.m_pData = payload
local results = Steam.NetworkingSockets.SendMessages(1, {msg})
if results[1] < 0 then
print('Send failed, EResult:', results[1])
end
- NetworkingSockets.SetConnectionName(hPeer, pszName)
🤖 Auto-generated binding
- Parameters:
hPeer (int - HSteamNetConnection) –
pszName (str?) –
- SteamWorks:
Example:
Steam.NetworkingSockets.SetConnectionName(hConn, 'Player_' .. playerName)
- NetworkingSockets.SetConnectionPollGroup(hConn, hPollGroup)
🤖 Auto-generated binding
- Parameters:
hConn (int - HSteamNetConnection) –
hPollGroup (int - HSteamNetPollGroup) –
- Returns:
(bool) Return value
- SteamWorks:
Example:
Steam.NetworkingSockets.SetConnectionPollGroup(hConn, hPollGroup)
- NetworkingSockets.SetConnectionUserData(hPeer, nUserData)
🤖 Auto-generated binding
- Parameters:
hPeer (int - HSteamNetConnection) –
nUserData (uint64) –
- Returns:
(bool) Return value
- SteamWorks:
Example:
-- Associate a player index with this connection for quick lookup
Steam.NetworkingSockets.SetConnectionUserData(hConn, playerIndex)
Unimplemented Methods
- NetworkingSockets.ReceivedRelayAuthTicket()
✋ Not implemented - unsupported type: SteamDatagramRelayAuthTicket *
- SteamWorks:
- NetworkingSockets.FindRelayAuthTicketForServer()
✋ Not implemented - unsupported type: SteamDatagramRelayAuthTicket *
- SteamWorks:
- NetworkingSockets.GetHostedDedicatedServerAddress()
✋ Not implemented - unsupported type: SteamDatagramHostedAddress *
- SteamWorks:
- NetworkingSockets.GetGameCoordinatorServerLogin()
✋ Not implemented - unsupported type: SteamDatagramGameCoordinatorServerLogin *
- SteamWorks:
- NetworkingSockets.ConnectP2PCustomSignaling()
✋ Not implemented - unsupported type: ISteamNetworkingConnectionSignaling *
- SteamWorks:
- NetworkingSockets.ReceivedP2PCustomSignal()
✋ Not implemented - unsupported type: ISteamNetworkingSignalingRecvContext *
- SteamWorks:
- NetworkingSockets.GetCertificateRequest()
✋ Not implemented - unsupported type: SteamNetworkingErrMsg &
- SteamWorks:
- NetworkingSockets.SetCertificate()
✋ Not implemented - unsupported type: SteamNetworkingErrMsg &
- SteamWorks:
- NetworkingSockets.CreateFakeUDPPort()
✋ Not implemented - unsupported type: ISteamNetworkingFakeUDPPort *
- SteamWorks:
Callbacks
- NetworkingSockets.OnSteamNetConnectionStatusChangedCallback()
Callback for SteamNetConnectionStatusChangedCallback_t
callback(data) receives:
data.m_hConn (int - HSteamNetConnection)
data.m_info (SteamNetConnectionInfo_t)
data.m_eOldState (int - ESteamNetworkingConnectionState)
Example:
function Steam.NetworkingSockets.OnSteamNetConnectionStatusChangedCallback(data)
local state = data.m_info.m_eState
if state == Steam.k_ESteamNetworkingConnectionState_Connected then
print('Connected:', data.m_hConn)
elseif state == Steam.k_ESteamNetworkingConnectionState_ClosedByPeer then
print('Disconnected:', data.m_hConn)
Steam.NetworkingSockets.CloseConnection(data.m_hConn, 0, nil, false)
end
end
- NetworkingSockets.OnSteamNetAuthenticationStatus()
Callback for SteamNetAuthenticationStatus_t
callback(data) receives:
data.m_eAvail (int - ESteamNetworkingAvailability)
data.m_debugMsg (string)
- NetworkingSockets.OnSteamNetworkingFakeIPResult()
Callback for SteamNetworkingFakeIPResult_t
callback(data) receives:
data.m_eResult (int - EResult)
data.m_identity (SteamNetworkingIdentity)
data.m_unIP (int)
data.m_unPorts (int)