Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:io
  3. RawSocketEvent class
RawSocketEvent
description

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

hashCodeint
The hash code for this object.
no setterinherited
runtimeTypeType
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.
  1. Dart
  2. dart:io
  3. RawSocketEvent class
dart:io library

[8]ページ先頭

©2009-2025 Movatter.jp