Coder Social home page Coder Social logo

jordan15 / flutter_tcp_example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from julianassmann/flutter_tcp_example

0.0 0.0 0.0 269 KB

Flutter app demonstrating the use of TCP sockets in Flutter.

License: MIT License

C++ 36.78% C 4.80% Objective-C 0.12% Kotlin 0.46% Dart 51.87% Swift 1.32% Batchfile 4.64%

flutter_tcp_example's Introduction

Flutter TCP Demo

This app demonstrantes how to use TCP sockets in a flutter app that 'chats' with a TCP server.

The app folder contains the actual flutter app. This app allows the user to create a TCP connection to a TCP server identified by a hostname and a port the user can enter. A chat-like UI allows to receive messages from and send messages to the server.

The server folder contains a very simple TCP server that accepts incoming connections. It shows incoming messages from the client and echoes them back to the client.

Screesnhot of the connection details page for entering server information. Screenshot of the chat page after connecting to the server.

Requirements

You need to have the Flutter installed.

Run

To start the server, go into the server folder and run

dart server.dart

To start the app, go into the app folder and run

flutter run

Configuration

In the server file (server/index.js) you can configure the hostname and port of the TCP server by setting the const values hostname and port. The client side/app is configured during the runtime of the app.

If you run the app in the Android Emulator, set the hostname in index.js to localhost and input the IP address 10.0.2.2 (the hosts IP address from inside the Android Emulator) in the app.

If you run the app on a real device, set the hostname in index.js and in the client app to the IP address of the machine in the local network (obtained via ifconfig (Linux) ipconfig (Windows)).

The ports specified in the server and the app must be the same.

Flutter app architecture

(Note: This is a quick and dirty example app)

This app uses the BLoC pattern to manage the state. TcpBloc manages the state of the TCP connection/socket and handling the incoming and outgoing messages.

Tools used

Pull requests are always welcome :)

Maintainer

Julian Aßmann

flutter_tcp_example's People

Contributors

julianassmann avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.