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

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!");

Libraries

client_server_sockets
Support for doing something awesome.