RawSocketEvent class
Events for theRawDatagramSocket,RawSecureSocket, andRawSocket.
These event objects are used by theStream behavior of the sockets(for exampleRawSocket.listen,RawSocket.forEach)when the socket's state change.
import 'dart:convert';import 'dart:io';void main() async { final socket = await RawSocket.connect("example.com", 80); socket.listen((event) { switch (event) { case RawSocketEvent.read: final data = socket.read(); if (data != null) { print(ascii.decode(data)); } break; case RawSocketEvent.write: socket.write(ascii.encode('GET /\r\nHost: example.com\r\n\r\n')); socket.writeEventsEnabled = false; break; case RawSocketEvent.readClosed: socket.close(); break; case RawSocketEvent.closed: break; default: throw "Unexpected event $event"; } });}Properties
- hashCode→int
- The hash code for this object.no setterinherited
- runtimeType→Type
- A representation of the runtime type of the object.no setterinherited
Methods
- noSuchMethod(
Invocationinvocation)→ dynamic - Invoked when a nonexistent method or property is accessed.inherited
- toString(
)→String - A string representation of this object.override
Operators
- operator ==(
Objectother)→bool - The equality operator.inherited
Constants
- closed→ constRawSocketEvent
- An event indicates the socket is closed.
- read→ constRawSocketEvent
- An event indicates the socket is ready to be read.
- readClosed→ constRawSocketEvent
- An event indicates the reading from the socket is closed
- write→ constRawSocketEvent
- An event indicates the socket is ready to write.