API reference
GDUDPPacketConn
UDP endpoint preserving packet boundaries and source addresses, with deadlines and Close wakeups.
Methods
read_from(max: int = 65536) -> Dictionary, Errread_from_async(max: int = 65536) -> await Dictionary, Errwrite_to(data: PackedByteArray, host: String, port: int) -> int, Errwrite_to_async(data: PackedByteArray, host: String, port: int) -> await int, Errset_deadline(seconds: float) -> Errset_read_deadline(seconds: float) -> Errset_write_deadline(seconds: float) -> Erraddr() -> Dictionaryis_open() -> boolclose() -> void
read_from
read_from(max: int = 65536) -> Dictionary, ErrStart receiving the next UDP packet.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
max | int | 65536 | Maximum bytes requested by one receive operation. |
Return value
Dictionary, Err
Suspends only the calling routine until the operation completes. No explicit await is needed.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
Returns a dictionary with data, host, port, and truncated. Packets are never merged.
read_from_async
read_from_async(max: int = 65536) -> await Dictionary, ErrStart receiving the next UDP packet.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
max | int | 65536 | Maximum bytes requested by one receive operation. |
Return value
await Dictionary, Err
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
Returns a dictionary with data, host, port, and truncated. Packets are never merged.
write_to
write_to(data: PackedByteArray, host: String, port: int) -> int, ErrStart sending a UDP packet to an IP address.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
data | PackedByteArray | Required | Input data in the representation shown by the parameter type. |
host | String | Required | Hostname or IP address used for connecting or binding. |
port | int | Required | Network port number. A listening port of zero lets the OS select a port. |
Return value
int, Err
Suspends only the calling routine until the operation completes. No explicit await is needed.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
write_to_async
write_to_async(data: PackedByteArray, host: String, port: int) -> await int, ErrStart sending a UDP packet to an IP address.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
data | PackedByteArray | Required | Input data in the representation shown by the parameter type. |
host | String | Required | Hostname or IP address used for connecting or binding. |
port | int | Required | Network port number. A listening port of zero lets the OS select a port. |
Return value
await int, Err
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
set_deadline
set_deadline(seconds: float) -> ErrSet both UDP receive and send deadlines.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
seconds | float | Required | Deadline setting in seconds; see this method for relative-time and clearing semantics. |
Return value
Err
Errors
Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.
set_read_deadline
set_read_deadline(seconds: float) -> ErrApply the UDP receive deadline to existing waits too.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
seconds | float | Required | Deadline setting in seconds; see this method for relative-time and clearing semantics. |
Return value
Err
Errors
Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.
set_write_deadline
set_write_deadline(seconds: float) -> ErrApply the UDP send deadline to existing waits too.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
seconds | float | Required | Deadline setting in seconds; see this method for relative-time and clearing semantics. |
Return value
Err
Errors
Returns an Err object directly, not a value-and-error pair. An absent error is null; inspect the method description to distinguish creation, lookup, and stored failure.
addr
addr() -> DictionaryReturn the UDP endpoint's listen address.
Parameters
No parameters.
Return value
Dictionary
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
is_open
is_open() -> boolCheck whether the UDP endpoint is open.
Parameters
No parameters.
Return value
bool
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
close
close() -> voidClose the UDP endpoint and wake all pending operations.
Parameters
No parameters.
Return value
void
No value is returned.
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.