Give the socket an Android log collection program with Client call demo

Source: Internet
Author: User

Source:
Solve real-time tracking debugging problem of mobile phone client.

Main Description:
It is mainly used to debug the collection of multi-terminal related log information function. Now LAN only. Use the extranet to ensure the mapping is correct.
such as. One app for multiple terminals at the same time. The embodiment of the test problem can be handled using this software.
The use of thread pooling on the software service side guarantees stability under large data volumes. In theory, any information interaction program that gives the socket is acceptable. Below are the Java client code that has been used for your reference.

Java Client Demo Code:

New Sendpclog (log). Start ();

Package cn.sj.soft;

Import java.io.IOException;
Import Java.io.OutputStream;
Import java.net.InetSocketAddress;
Import Java.net.socket;import
Java.net.SocketTimeoutException;
Import Java.net.URLEncoder;

/**

* Send log file to PC location error Android
* @author ZW
*/

public class Sendpclog extends Thread {
private static String HOST = "192.168.1.88";
private static int PORT = 19730;
static String buffer = "";
static socket socket = NULL;
Public String txt1;
Public Sendpclog (String str) {
Txt1 = android.os.build.model+ ":" +STR;
}

@Override
public void Run () {

Defining messages
try {
Connect to the server and set the connection timeout to 5 seconds
Socket = new socket ();
Socket.connect (New Inetsocketaddress (HOST, PORT), 5000);
Get input and output stream
OutputStream OU = Socket.getoutputstream ();
Sending information to the server
Ou.write (Urlencoder.encode (txt1, "Utf-8"). GetBytes ());
Ou.flush ();
Ou.close ();
Socket.close ();
} catch (Sockettimeoutexception aa) {
Bundle.putstring ("MSG", "Server Connection failed!") Please check if the network is turned on ");

} catch (IOException e) {
E.printstacktrace ();

}

}

}

Details: http://www.shijieweb.cn/post/1cc4ef53_40fc277

Category: World Jie series software original works

Give the socket an Android log collection program with Client call demo

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.