Chat programs for Android and swing clients

Source: Internet
Author: User

Chat program, swing server, client for Android and swing, can communicate with each other, realize the functions such as:

Basic ideas:

Start the server:

Start the server thread, wait for the client to connect, start the broadcast thread, and send the message to the client

Starts the client thread, maintains the server's connection to a single client, and receives messages sent from the client.

Android and Swing clients:

Log in to chat: Get the input and output streams connected to the server and communicate with each other

The client is also a thread object that listens for information sent from the server and updates the interface.

Main implementation of the technology: Socket network programming, thread multithreading

The approximate flowchart is as follows:

In fact, with Android and swing client, in terms of coding is no difference, are socket communication, just The use of Android in the update interface, can not be updated through the non-main thread, because Android is threaded, the update interface must be in the main thread inside the operation, the other is only the control API is different: Swing buttons, text boxes, etc. need to be generated in code new, Controls in Android can be defined in an XML file, reducing memory usage, and virtually the interface in Android is similar to swing!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.