Skip to main content

API

TransportServersFactoryโ€‹

Declaration
class TransportServersFactory {
TransportServer tcp(
InternetAddress address,
int port,
void Function(TransportServerConnection connection) onAccept, {
TransportTcpServerConfiguration? configuration,
})
TransportServerDatagramReceiver udp(
InternetAddress address,
int port, {
TransportUdpServerConfiguration? configuration,
})
TransportServer unixStream(
String path,
void Function(TransportServerConnection connection) onAccept, {
TransportUnixStreamServerConfiguration? configuration,
})
}

Methodsโ€‹

tcpโ€‹

Creates TCP server.

udpโ€‹

Creates UDP server.

unixStreamโ€‹

Creates UNIX Socket server.

TransportServerConnectionโ€‹

Declaration
class TransportServerConnection {
Stream<TransportPayload> get inbound
bool get active
Future<void> read()
Stream<TransportPayload> stream()
void writeSingle(Uint8List bytes, {void Function(Exception error)? onError, void Function()? onDone})
void writeMany(List<Uint8List> bytes, {bool linked = true, void Function(Exception error)? onError, void Function()? onDone})
Future<void> close({Duration? gracefulTimeout})
Future<void> closeServer({Duration? gracefulTimeout})
}

Propertiesโ€‹

activeโ€‹

Server connection live status.

inboundโ€‹

Stream for inbound (read) payloads.

Methodsโ€‹

readโ€‹

Initiates a read event for new data from the connection.

streamโ€‹

Automatically reads a stream of inbound data from the connection.

writeSingleโ€‹

Writes a single buffer to the connection.

writeManyโ€‹

Writes many buffers to the connection.

closeโ€‹

Closes the connection.

closeServerโ€‹

Closes the server. It will close all TCP connections and also will stop UDP processing.

TransportServerDatagramReceiverโ€‹

Declaration
class TransportServerDatagramReceiver {
Stream<TransportServerDatagramResponder> get inbound
bool get active
Stream<TransportServerDatagramResponder> receive({int? flags})
Future<void> close({Duration? gracefulTimeout})
}

Propertiesโ€‹

inboundโ€‹

Stream for inbound (read) payloads.

activeโ€‹

Server live status.

Methodsโ€‹

streamโ€‹

Automatically reads a stream of inbound data from the sender.

closeServerโ€‹

Closes the server. It will close all TCP connections and also will stop UDP processing.

TransportServerDatagramResponderโ€‹

Declaration
class TransportServerDatagramResponder {
Uint8List get receivedBytes
bool get active
void respondSingle(Uint8List bytes, {int? flags, void Function(Exception error)? onError, void Function()? onDone})
void respondMany(List<Uint8List> bytes, {int? flags, bool linked = true, void Function(Exception error)? onError, void Function()? onDone})
void release()
Uint8List takeBytes({bool release = true})
List<int> toBytes({bool release = true})
}

Propertiesโ€‹

receivedBytesโ€‹

Current datagram bytes from the sender.

activeโ€‹

Responder live status.

Methodsโ€‹

respondSingleโ€‹

Responds with a single message to the sender.

respondManyโ€‹

Responds with many messages to the sender.

releaseโ€‹

Returns responder to a pool and clears it.

takeBytesโ€‹

Takes Uint8List from the payload and releases the responder.

toBytesโ€‹

Takes List<int> from the payload and releases the responder.