CreateNetChannel
CNetChan gameserver.CreateNetChannel( string ip, boolean useDNS, number protocolVersion = 1, number socket = NS_SERVER )
Description
Creates a net channel for the given ip.
Recently Changed
This was recently changed in version (0.8 - DEV).
The protocolVersion
and socket
arguments were added.
Arguments
Returns
Example
Example implementation of creating a working connection between two servers
return true end) function SendNetMessage(target, bf, reliable) for _, netChan in ipairs(netChannels) do if not netChan:IsValid() then continue end if netChan:GetName() != target then continue end return netChan:SendMessage(bf, reliable) end return false end hook.Add("Think", "UpdateNetChannels", function() for _, netChan in ipairs(netChannels) do if not netChan:IsValid() then continue end netChan:ProcessStream() -- process any incomming messages netChan:Transmit() -- Transmit out a update. end end) -- Install the script on two servers. -- call BuildNetChannel with the target on one of the servers and on both servers a net channel is created BuildNetChannel("127.0.0.1:27015")