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

List of Functions

List of Callbacks

Function Reference

NetworkingSockets.AcceptConnection(hConn)

🤖 Auto-generated binding

Parameters:

hConn (int - HSteamNetConnection) –

Returns:

(int - EResult) Return value

SteamWorks:

AcceptConnection

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:

BeginAsyncRequestFakeIP

NetworkingSockets.CloseConnection(hPeer, nReason, pszDebug, bEnableLinger)

🤖 Auto-generated binding

Parameters:
  • hPeer (int - HSteamNetConnection) –

  • nReason (int) –

  • pszDebug (str?) –

  • bEnableLinger (bool) –

Returns:

(bool) Return value

SteamWorks:

CloseConnection

Example:

Steam.NetworkingSockets.CloseConnection(hConn, 0, 'Player left', false)
NetworkingSockets.CloseListenSocket(hSocket)

🤖 Auto-generated binding

Parameters:

hSocket (int - HSteamListenSocket) –

Returns:

(bool) Return value

SteamWorks:

CloseListenSocket

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 pLanePriorities and pLaneWeights

  • pLanePriorities (int[]?) –

  • pLaneWeights (int[]?) –

Returns:

(int - EResult) Return value

SteamWorks:

ConfigureConnectionLanes

NetworkingSockets.ConnectByIPAddress(address, nOptions, pOptions)

🤖 Auto-generated binding

Parameters:
Returns:

(int - HSteamNetConnection) Return value

SteamWorks:

ConnectByIPAddress

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:
Returns:

(int - HSteamNetConnection) Return value

SteamWorks:

ConnectP2P

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:
Returns:

(int - HSteamNetConnection) Return value

SteamWorks:

ConnectToHostedDedicatedServer

NetworkingSockets.CreateHostedDedicatedServerListenSocket(nLocalVirtualPort, nOptions, pOptions)

🤖 Auto-generated binding

Parameters:
Returns:

(int - HSteamListenSocket) Return value

SteamWorks:

CreateHostedDedicatedServerListenSocket

NetworkingSockets.CreateListenSocketIP(localAddress, nOptions, pOptions)

🤖 Auto-generated binding

Parameters:
Returns:

(int - HSteamListenSocket) Return value

SteamWorks:

CreateListenSocketIP

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:
Returns:

(int - HSteamListenSocket) Return value

SteamWorks:

CreateListenSocketP2P

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:
Returns:

(int - HSteamListenSocket) Return value

SteamWorks:

CreateListenSocketP2PFakeIP

NetworkingSockets.CreatePollGroup()

🤖 Auto-generated binding

Returns:

(int - HSteamNetPollGroup) Return value

SteamWorks:

CreatePollGroup

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:
Returns:

(bool) Return value

Returns:

(int) pOutConnection1

Returns:

(int) pOutConnection2

SteamWorks:

CreateSocketPair

Signature differences from C++ API:

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

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

DestroyPollGroup

Example:

Steam.NetworkingSockets.DestroyPollGroup(hPollGroup)
NetworkingSockets.FlushMessagesOnConnection(hConn)

🤖 Auto-generated binding

Parameters:

hConn (int - HSteamNetConnection) –

Returns:

(int - EResult) Return value

SteamWorks:

FlushMessagesOnConnection

Example:

Steam.NetworkingSockets.FlushMessagesOnConnection(hConn)
NetworkingSockets.GetAuthenticationStatus()

🤖 Auto-generated binding

Returns:

(int - ESteamNetworkingAvailability) Return value

Returns:

(SteamNetAuthenticationStatus_t) pDetails

SteamWorks:

GetAuthenticationStatus

Signature differences from C++ API:

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

GetConnectionInfo

Signature differences from C++ API:

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

Returns:

(bool) Return value

Returns:

(str) pszName

SteamWorks:

GetConnectionName

Signature differences from C++ API:

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

(SteamNetConnectionRealTimeLaneStatus_t) pLanes

SteamWorks:

GetConnectionRealTimeStatus

Signature differences from C++ API:

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

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

GetConnectionUserData

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

Returns:

(int) Return value

Returns:

(str) pszBuf

SteamWorks:

GetDetailedConnectionStatus

Signature differences from C++ API:

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

GetFakeIP

Signature differences from C++ API:

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

GetHostedDedicatedServerPOPID

NetworkingSockets.GetHostedDedicatedServerPort()

🤖 Auto-generated binding

Returns:

(int) Return value

SteamWorks:

GetHostedDedicatedServerPort

NetworkingSockets.GetIdentity()

🤖 Auto-generated binding

Returns:

(bool) Return value

Returns:

(SteamNetworkingIdentity) pIdentity

SteamWorks:

GetIdentity

Signature differences from C++ API:

  • Parameter pIdentity 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, 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:

GetListenSocketAddress

Signature differences from C++ API:

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

GetRemoteFakeIPForConnection

Signature differences from C++ API:

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

InitAuthentication

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 call Release on all of them after using.

SteamWorks:

ReceiveMessagesOnConnection

Receives messages that have been sent to a connection.

Signature differences from C++ API:

  • Parameter ppOutMessages is 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 call Release on all of them after using.

SteamWorks:

ReceiveMessagesOnPollGroup

Receives messages that have arrived on any connection in a poll group.

Signature differences from C++ API:

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

ResetIdentity

NetworkingSockets.RunCallbacks()

🤖 Auto-generated binding

SteamWorks:

RunCallbacks

NetworkingSockets.SendMessageToConnection(hConn, pData, cbData, nSendFlags)

🤖 Auto-generated binding

Parameters:
  • hConn (int - HSteamNetConnection) –

  • pData (str?) –

  • cbData (int) – size of the input array pData

  • nSendFlags (int) –

Returns:

(int - EResult) Return value

Returns:

(uint64) pOutMessageNumber

SteamWorks:

SendMessageToConnection

Signature differences from C++ API:

  • Parameter pOutMessageNumber is 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 pMessages

  • pMessages (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:

SendMessages

Sends one or more messages to one or more connections in a single call.

Signature differences from C++ API:

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

SetConnectionName

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:

SetConnectionPollGroup

Example:

Steam.NetworkingSockets.SetConnectionPollGroup(hConn, hPollGroup)
NetworkingSockets.SetConnectionUserData(hPeer, nUserData)

🤖 Auto-generated binding

Parameters:
  • hPeer (int - HSteamNetConnection) –

  • nUserData (uint64) –

Returns:

(bool) Return value

SteamWorks:

SetConnectionUserData

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:

ReceivedRelayAuthTicket

NetworkingSockets.FindRelayAuthTicketForServer()

Not implemented - unsupported type: SteamDatagramRelayAuthTicket *

SteamWorks:

FindRelayAuthTicketForServer

NetworkingSockets.GetHostedDedicatedServerAddress()

Not implemented - unsupported type: SteamDatagramHostedAddress *

SteamWorks:

GetHostedDedicatedServerAddress

NetworkingSockets.GetGameCoordinatorServerLogin()

Not implemented - unsupported type: SteamDatagramGameCoordinatorServerLogin *

SteamWorks:

GetGameCoordinatorServerLogin

NetworkingSockets.ConnectP2PCustomSignaling()

Not implemented - unsupported type: ISteamNetworkingConnectionSignaling *

SteamWorks:

ConnectP2PCustomSignaling

NetworkingSockets.ReceivedP2PCustomSignal()

Not implemented - unsupported type: ISteamNetworkingSignalingRecvContext *

SteamWorks:

ReceivedP2PCustomSignal

NetworkingSockets.GetCertificateRequest()

Not implemented - unsupported type: SteamNetworkingErrMsg &

SteamWorks:

GetCertificateRequest

NetworkingSockets.SetCertificate()

Not implemented - unsupported type: SteamNetworkingErrMsg &

SteamWorks:

SetCertificate

NetworkingSockets.CreateFakeUDPPort()

Not implemented - unsupported type: ISteamNetworkingFakeUDPPort *

SteamWorks:

CreateFakeUDPPort

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)