> For the complete documentation index, see [llms.txt](https://lua2.fatality.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lua2.fatality.win/api/instances/game/cengineclient/cnetchan.md). Agents can also search and read this documentation through its [MCP server](https://lua2.fatality.win/~gitbook/mcp).

# CNetChan

Provides a way to interface with a Network Channel's class.

## GetAddress

<mark style="color:purple;">**`Method`**</mark>

{% hint style="danger" %}
If the current channel is `null`, this function will return `nil` instead.
{% endhint %}

Returns address string of the remote machine.

**Arguments**

None.

**Returns**

| Type      | Description                         |
| --------- | ----------------------------------- |
| `string?` | IP-address or Steam Server Address. |

**Example**

```lua
local chan = game.engine:GetNetChan();
if chan and not chan:IsNull() then
    print(chan:GetAddress());
end
```

***

## IsLoopback

<mark style="color:purple;">**`Method`**</mark>

{% hint style="danger" %}
If the current channel is `null`, this function will return `nil` instead.
{% endhint %}

Returns whether the current channel is connected to the local machine (loopback address).

**Arguments**

None.

**Returns**

| Type    | Description                               |
| ------- | ----------------------------------------- |
| `bool?` | `true` if connected to the local machine. |

Example

```lua
local chan = game.engine:GetNetChan();
if chan and not chan:IsNull() and chan:IsLoopback() then
    print('Connected to localhost!');
end
```

***

## IsNull

<mark style="color:purple;">**`Method`**</mark>

Returns whether the channel is stubbed.

**Arguments**

None.

**Returns**

| Type   | Description                                   |
| ------ | --------------------------------------------- |
| `bool` | `true` if current channel is a dummy channel. |

Example

```lua
local chan = game.engine:GetNetChan();
if not chan or chan:IsNull() then
    print('Not connected!');
end
```

***

## GetLatency

<mark style="color:purple;">**`Method`**</mark>

{% hint style="danger" %}
If the current channel is `null`, this function will return `nil` instead.
{% endhint %}

Returns current latency to the remote server (in seconds).

**Arguments**

None.

**Returns**

| Type     | Description           |
| -------- | --------------------- |
| `float?` | Latency (in seconds). |

**Example**

```lua
local chan = game.engine:GetNetChan();
if chan and not chan:IsNull() then
    print('Current latency: ' .. tostring(math.round(chan:GetLatency() * 1000.0)) .. 'ms');
end
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://lua2.fatality.win/api/instances/game/cengineclient/cnetchan.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
