Compile Java NIO Socket testing tool and nio Testing Tool

Source: Internet
Author: User

Compile Java NIO Socket testing tool and nio Testing Tool

In the past year, we have been exposed to some server programs written using Java NIO. The client program calls the transaction interface provided by the server by establishing a Socket connection and sending messages.

During development, you usually need to send some messages to debug the program, so you can write a tool by yourself. The tool is written in Swing to send request messages to specified IP addresses and ports and receive response messages. Very simple, but enough.

 

The Source Code involves the following:

(1) EDT threads and task threads in Java Swing programming perform time-consuming operations in backend task threads and update the UI when appropriate;

(2) provides a Swing interface construction method: constructing Component, loading data, and adding Listener;

(3) GridBagLayout;

(4) use TitledBorder to create controls similar to GroupBox effects;

(5) General UIUpdater class for background threads to update the UI and decouple background threads and UI Component (which can be improved );

(6) since most Swing APIs are NOT thread-safe, all UI updates are put in the EDT thread, including the code for creating the top-level JFrame in the Main function;

(7) sending and receiving messages through NIO SocketChannel;

(8) the entire message is read cyclically without knowing the message length;

 

Run Interface

 

For the source code and Jar packages, see the attachment below and provide a simple EchoServer.

Click to download

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.