Protocol: net, part 1 of 2#
The net commands a program sends to a running game, as the engine describes them: what each takes, what it answers and what it does. Back to all commands.
net.host#
net.host {address?: text, delay?: integer, window?: integer, sync_every?: integer} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]} · write
Opens a session to play the game with other peers, as its host (peer 0, player 0), on a UDP socket: a game with 2 to 8 players ([input] players), each peer one player. Refused for a game of one player or with no actions (E0545), in C# (E0543, not yet), or whose moment put back does not go on the same on its recording (E0540), and while a session is open (E0544). The game begins at the first net.run once every player has joined. delay, window and sync_every are the project's [net] table's when left out.
| Parameters | Type | Meaning |
|---|---|---|
address? | text | Where to listen, IP:PORT. Left out: 127.0.0.1:0, a free port on this machine only. |
delay? | integer | Steps of input delay, 0 to 8. |
window? | integer | Steps of rollback, 1 to 16. |
sync_every? | integer | Steps between checksums, 1 to 600. |
| Result | Type | Meaning |
|---|---|---|
player | integer | The player this peer owns: its peer number. The host is 0. |
players | integer | How many players the game has: [input] players. |
host | value | Whether this peer opened the session. |
address | text | Where this peer's socket is, 127.0.0.1:PORT. |
started | value | Whether the game has begun: every player is in and a net.run has played. |
played | integer | The steps played: the step the game stands at, some of it predicted. |
confirmed | integer | The newest step every player's real input is in for: never played again, its checksum final. |
delay | integer | Steps between a local input and the step it is for. |
window | integer | The most steps played ahead of the confirmed one. |
sync_every | integer | Steps between two exchanges of the world's checksum. |
counters | record | {steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds. |
link | record | {sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition. |
peers | [record] | One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard. |
desync | record | null while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on. |
token | integer | This peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams. |
open | [record] | One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest. |
join | record | null, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent. |
words | text | What a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say. |
sums | [text] | With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty. |
net.join#
net.join {address: text, token?: integer, timeout_ms?: integer} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]} · write
Joins the session a host opened, and waits until it has every player (the host takes peers in its net.run): answers this peer's player. The game's files must be the host's, file for file (E0541). A game under way takes a late joiner into an open seat (net.run's begin_with): the next net.run fetches the game's confirmed moment and catches up; refused with no seat open or while another joins (E0546), or for a moment over 1,000,000 bytes (E0568). A host that does not answer in timeout_ms is E0549.
| Parameters | Type | Meaning |
|---|---|---|
address | text | The host's address, as net.host answered it: IP:PORT. |
token? | integer | The token of the seat this player had (net.status's token), to come back to it in the game under way: a seat whose player left is refused to anyone without it (E0569). |
timeout_ms? | integer | How long to wait. Left out: 10000. |
| Result | Type | Meaning |
|---|---|---|
player | integer | The player this peer owns: its peer number. The host is 0. |
players | integer | How many players the game has: [input] players. |
host | value | Whether this peer opened the session. |
address | text | Where this peer's socket is, 127.0.0.1:PORT. |
started | value | Whether the game has begun: every player is in and a net.run has played. |
played | integer | The steps played: the step the game stands at, some of it predicted. |
confirmed | integer | The newest step every player's real input is in for: never played again, its checksum final. |
delay | integer | Steps between a local input and the step it is for. |
window | integer | The most steps played ahead of the confirmed one. |
sync_every | integer | Steps between two exchanges of the world's checksum. |
counters | record | {steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds. |
link | record | {sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition. |
peers | [record] | One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard. |
desync | record | null while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on. |
token | integer | This peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams. |
open | [record] | One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest. |
join | record | null, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent. |
words | text | What a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say. |
sums | [text] | With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty. |
net.run#
net.run {steps: integer, input?: text, timeout_ms?: integer, begin_with?: integer, until?: integer} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]} · write
Plays the game with its peers for a number of steps, as fast as their inputs come: this peer's player's input is its held input (input.set) or, with input "recorded", the project's recording for that player. Missing inputs are predicted and rolled back when they come. It returns once the steps are played and confirmed and every peer holds this peer's inputs of them, or once two worlds were found to differ (desync). A peer silent for timeout_ms is E0549.
| Parameters | Type | Meaning |
|---|---|---|
steps | integer | How many steps to play, from 1 to 36000. |
input? | text | "held" (the default) or "recorded". |
timeout_ms? | integer | How long a peer may be silent, and a late joiner the host serves. Left out: 10000. |
begin_with? | integer | The host's, before the game begins: begin once this many players are in, the others' seats open to a late joiner (net.join to a game under way). Left out: every player. |
until? | integer | Play to this step, in place of steps more than the steps played: a late joiner's run, which begins at the moment it was sent. |
| Result | Type | Meaning |
|---|---|---|
player | integer | The player this peer owns: its peer number. The host is 0. |
players | integer | How many players the game has: [input] players. |
host | value | Whether this peer opened the session. |
address | text | Where this peer's socket is, 127.0.0.1:PORT. |
started | value | Whether the game has begun: every player is in and a net.run has played. |
played | integer | The steps played: the step the game stands at, some of it predicted. |
confirmed | integer | The newest step every player's real input is in for: never played again, its checksum final. |
delay | integer | Steps between a local input and the step it is for. |
window | integer | The most steps played ahead of the confirmed one. |
sync_every | integer | Steps between two exchanges of the world's checksum. |
counters | record | {steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds. |
link | record | {sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition. |
peers | [record] | One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard. |
desync | record | null while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on. |
token | integer | This peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams. |
open | [record] | One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest. |
join | record | null, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent. |
words | text | What a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say. |
sums | [text] | With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty. |
Generated from Coldwave 0.0.1 r289, 2026-11-30 by the binary itself: do not edit by hand.