Skip to content
pubscout

tcp_socket_connection

0.3.1, released 4 years ago by an unverified publisher

Flutter package to connect, listen to, and send messages over TCP sockets.

$ flutter pub add tcp_socket_connection
Source repository

What it does

Allows Flutter applications to establish a TCP socket connection with an IP address and port. It provides methods to connect asynchronously, listen for messages with or without an end-of-message (EOM) delimiter, and send text messages encoded in UTF-8.

AI-written summary of version 0.3.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to communicate directly with a backend or device over raw TCP sockets.
  • You are building a custom text-based protocol over TCP in Flutter.

Skip it when

  • You are working with high-level protocols like HTTP, WebSockets, or gRPC where standard networking packages are more suitable.

Strengths

  • Supports connecting with timeout and retry attempts.
  • Handles reading data via UTF-8 encoding with optional EOM (End of Message) splits.
  • Includes helper method to check connectivity before connecting.

Weaknesses

  • Limited to raw TCP sockets and UTF-8 string messages.
  • No documentation regarding binary data handling.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
TcpSocketConnection socketConnection = TcpSocketConnection("192.168.1.113", 10251);
await socketConnection.connect(5000, (String msg) {
  print(msg);
});
socketConnection.sendMessage("Hello");

Alternatives

Packages that do the same job and could replace tcp_socket_connection.