tcp_socket_flutter

Creator: coderz1093

Last updated:

0 purchases

tcp_socket_flutter Image
tcp_socket_flutter Images

Languages

Categories

Add to Cart

Description:

tcp socket flutter

TCP Socket Flutter #

Introduction
Set up
License and contributors

Introduction #
This is a Flutter package that allows you to connect to a socket over the net. All data is then read using UTF-8.
Setup #
Config
TCPSocketSetUp.setConfig(
const SocketConfig(
port: 8000,
numberSplit: 10000,
timeoutEachTimesSendData: Duration(milliseconds: 50),
),
);
copied to clipboard
Device Info
await TCPSocketSetUp.init();
copied to clipboard
Server
final TCPSocketServer _server = TCPSocketServer();
final result = await _server.initServer(
onData: (ip, sourcePort, event) {
print('Server receive data from: $ip:$sourcePort');
print('Server receive data: $event');
},
onDone: (ip, sourcePort) {},
onError: (error, ip, sourcePort) {},
);
print(result);
copied to clipboard
Server send data
await _server.sendData(
FormDataSending(
type: 'Server send info',
data: getRandomString(1000000),
),
);
copied to clipboard
Client
final TCPSocketClient _client = TCPSocketClient();
final result = await _client.connectToServer(
'192.168.0.101',
onData: (event) {
print('Client receive data: $event');
},
onDone: () {},
onError: (error) {},
);
print('Connect to server $result');
copied to clipboard
Client send data
await _client.sendData(
FormDataSending(
type: 'Client send info',
data: getRandomString(1000000),
),
);
copied to clipboard
License and contributors #

The MIT License, see LICENSE.
For contributors, see AUTHORS.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.