tcp_link 1.0.0 copy "tcp_link: ^1.0.0" to clipboard
tcp_link: ^1.0.0 copied to clipboard

Simplified TCP/IP Communication

This package provides functionality for TCP/IP communication between devices.

Please refer to https://github.com/BenediktJSchlegel/tcp_link/tree/master/example for example usage.

Basic Usage: #

Sending: #

  1. Initialize the Sender
final sender = LinkSender(
    loggingConfiguration: LoggingConfiguration.print(LoggingVerbosity.info),
    configuration: SenderConfiguration("<SENDER_IP>", 10),
);
  1. Send some data
DataSendResult sendResult = await sender.sendString(SenderTarget("<TARGET_IP>", <PORT>), "This is my data!");

Receiving: #

  1. Register and start the Receiver
final receiver = LinkReceiver(
    onTransferPermissionRequestedCallback: (request) => _onHandshakeReceived(request),
    loggingConfiguration: LoggingConfiguration.print(LoggingVerbosity.info),
    config: LinkConfiguration(ip: "<IP>", port: <PORT>, bufferPath: "<PATH_TO_BUFFER_TO>"),
);

receiver.start();
  1. Define the Handshake-Callback. This will handle the receiving of data once a handshake is accepted.
  Future<void> _onHandshakeReceived(PermissionRequest request) async{
    request.accept().listen((event) {
      switch (event.runtimeType) {
        case ProgressReceiveEvent:
          print("Made Progress!");
          break;
        case FailedReceiveEvent:
          print("Failed");
          break;
        case DoneReceiveEvent:
          print("Finished");
          break;
      }
    });
  }
img_1.png img_2.png img_3.png
2
likes
140
points
4
downloads

Publisher

unverified uploader

Weekly Downloads

Simplified TCP/IP Communication

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, path

More

Packages that depend on tcp_link