client_server_sockets 0.0.1 copy "client_server_sockets: ^0.0.1" to clipboard
client_server_sockets: ^0.0.1 copied to clipboard

outdated

A simple client-server sockets package that uses the Socket and ServerSocket classes.

A simple client-server sockets package that uses the Socket and ServerSocket classes.

Getting started #

Add the dependency:

dependencies:
  sockets: ^0.0.1

Import the package:

import 'package:sockets/sockets.dart';

Usage #

Start the server on an address you want:

Server server = Server();
await server.startServer("192.168.1.2");

Add the callback function to prevent it from throwing a null exception:

server.onSocketDone = (port) {
    // Logic for when socket is closed
};

Listen to the response stream:

server.stream.listen(print);

Now initialize the client and connect to the server:

Client client = Client();
await client.connect("192.168.1.2");

Add the callback function to prevent it from throwing a null exception:

client.onSocketDone = () {
  // Logic for when socket is closed
};

Listen to the response stream:

client.stream.listen(print);

To send a message to the server, use the send() function like this:

client.send("Hello World!");
3
likes
0
pub points
45%
popularity

Publisher

unverified uploader

A simple client-server sockets package that uses the Socket and ServerSocket classes.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

args

More

Packages that depend on client_server_sockets