UdpSocket class

Manages a UDP socket.

UDP differs from TCP in the sense that it does not make any guarantees when sending messages and does not monitor its own connections. Because of this, it is much faster than TCP, which is why we are using it across the rover. Extend this class to implement your own UDP socket.

  • Call init to open the socket on the given port.
  • Call send to send raw data to another socket.
  • Call dispose to close the socket.
  • Use stream to listen to new packets (Datagrams) as they arrive over the socket.
Inheritance
Implementers

Constructors

UdpSocket({required int? port, bool quiet = false, SocketInfo? destination})
Opens a UDP socket on the given port that can send and receive data.

Properties

destination SocketInfo?
The destination port to send to.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
logger BurtLogger
A logger to capture important events during operation.
final
messages Stream<WrappedMessage>
Wraps all incoming data in a WrappedMessage.
no setter
port int?
The port this socket is listening on. See RawDatagramSocket.bind.
no setter
quiet bool
Whether to silence "normal" output, like opening/closing and resetting sockets.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream Stream<Datagram>
A stream containing all the data coming out of the socket.
no setter

Methods

dispose() Future<void>
Closes the connection to the device.
override
init() Future<bool>
Initializes the connection to the device.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onDisconnect() Future<void>
A callback to run when the program has disconnected from the Dashboard.
inherited
send(List<int> data, {SocketInfo? destination}) → void
Sends data to the given destination.
sendMessage(Message message, {SocketInfo? destination}) → void
Sends a Message over the socket (in a WrappedMessage).
sendWrapper(WrappedMessage wrapper, {SocketInfo? destination}) → void
Sends a WrappedMessage over the socket.
toString() String
A string representation of this object.
inherited

Operators

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

Constants

allowedErrors → const Set<int>
A collection of allowed OSError codes.