SrtSocket class

Represents an SRT (Secure Reliable Transport) socket

An SrtSocket wraps the native SRT C API and provides:

  • Connection establishment (bind, listen, accept, connect)
  • Data transmission (send, receive)
  • Configuration (socket options)
  • State inspection (status, statistics)

Basic usage:

// Create and connect as client
final socket = SrtSocket();
await socket.connect('192.168.1.100', 4200);
socket.send(Uint8List.fromList([1, 2, 3]));
final data = socket.recv(1024);

// Or bind and listen as server
final serverSocket = SrtSocket();
serverSocket.bind('0.0.0.0', 4200);
serverSocket.listen();
final client = serverSocket.accept();

// afterwards dispose the socket
*.dispose();

Constructors

SrtSocket({SocketOptions? options})
Create a new SRT socket
SrtSocket.fromHandle(int handle)
Internal: Create from an existing socket handle (for accept())

Properties

acceptIsloate Isolate?
The current Isolate of an accept method
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isClosed bool
Check if this socket is currently closed
no setter
options SocketOptions?
Options of the socket.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
socketHandle int
Get the socket handle
no setter
status SRT_SOCKSTATUS
Get the current status of this socket
no setter
waitIsloate Isolate?
The current Isolate of an wait method (Stream)
getter/setter pair

Methods

accept() Future<SrtSocket>
Accept an incoming connection on this socket
bind(InternetAddress address, int port) → void
Bind this socket to the specified address and port
connect(InternetAddress address, int port) → void
Connect this socket to a remote InternetAddress
dispose() → void
Close this socket and release its resources
getLocalAddress() SocketInterface
Get the local address this socket is bound to
getRemoteAddress() SocketInterface
Get the remote address this socket is connected to
getStats({bool clear = false}) SocketStats
Get transmission statistics for this socket
listen({int backlog = 1, AcceptConnectionCallback? onAccept}) ListenStats
Listen for incoming connections on this socket
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recvFile(String outputPath, {int offset = 0, int size = 0, int blockSize = 262144}) int
Receive a file over this socket
recvMessage({int bufferSize = 1500}) SrtMessage
Receive a message from this socket
recvStream(int timeoutMs, {int bufferSize = 1500}) Uint8List
Receive data from this socket in stream mode
sendFile(String filePath, {int offset = 0, int size = 0, int blockSize = 262144}) int
Send a file over this socket
sendMessage(String text, {MessageControl control = const MessageControl()}) int
Send a message over this socket
sendStream(Uint8List data, {bool chunked = false}) int
Send data over this socket in stream mode
toString() String
A string representation of this object.
inherited
waitMessage({int bufferSize = 1500}) Stream<SrtMessage>
Receive messages from this socket as a Stream
waitStream({int bufferSize = 1500, int timeoutMs = 100, required void onReceive(Uint8List data)}) Future<void>
Receive data from this socket in a continuous stream.

Operators

operator ==(Object other) bool
The equality operator.
inherited