gdDocumentation0.8.0

API reference

GDTCPListener

TCP listener with deadlines and Close wakeups for pending accepts.

Methods

accept

accept() -> GDTCPConn, Err

Start accepting the next TCP connection.

Parameters

No parameters.

Return value

GDTCPConn, 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.

accept_async

accept_async() -> await GDTCPConn, Err

Start accepting the next TCP connection.

Parameters

No parameters.

Return value

await GDTCPConn, 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) -> Err

Set the accept deadline in seconds from now.

Parameters

NameTypeDefaultDescription
secondsfloatRequiredDeadline 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() -> Dictionary

Return the 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() -> bool

Check whether the listener 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() -> void

Close the listener and wake all pending accepts.

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.