"Android Interview Treasure" study notes (seventh: Network and encryption)

Source: Internet
Author: User

What information do I need to specify at least to create a socket object?

IP and port number:

Socket socket = new Socket ("www.microsoft.com", 80);


The socket connects to the server and the server-side interaction code:

Http://www.cnblogs.com/linzheng/archive/2011/01/23/1942328.html


Under what circumstances will the socket be closed?

1:socket.close method;

2:inputstream and OutputStream have a close;

3: The network connection automatically shuts down when the program exits;

The 4:socket object is set to null or after the new socket object is freed.


How do I connect to a server using the Socket.connect method?

Socket socket = new socket (); Socket.connect (New Inetsocketaddress ("192.168.18.100", 8080));

How do I set the connection timeout?

Socket.connect (New Inetsocketaddress ("192.168.18.100", 8080), 2000);

What are the getter methods for the socket class?

Socket.getinetaddress (). GetHostName ();
Socket.getinetaddress (). Getport ();
Socket.getinetaddress (). getremotesocketaddress ();
Socket.getinetaddress (). getlocaladdress ();
Socket.getinetaddress (). Getlocalport ();
Socket.getinetaddress (). getlocalsocketaddress ();
Socket.getinetaddress (). getremotesocketaddress ();

How do I ensure that all data is sent to the server after the Socket.close method?

Socket.setsolinger (True, 30);

Socket options:

Http://www.open-open.com/lib/view/open1412994697952.html


Socket exception handling?

Http://www.educity.cn/java/505626.html


How do I create a service-side socket?

ServerSocket serversocket = new ServerSocket (1234);


How do I set the request queue length?

ServerSocket serversocket = new ServerSocket (1234,100);


What is the difference between synchronous/asynchronous/blocking and non-blocking I/O?

Synchronization: When a function call is made, the call does not return until the result is obtained.

Async: When an asynchronous procedure call is made, the caller cannot get the result immediately. The part that actually handles the call notifies the caller via status, notification, and callback after completion.

Blocking: The current thread is suspended until the call results are returned (the thread goes into a non-executable state, in which case the CPU does not assign a time slice to the thread, that is, the thread pauses to run). Functions are returned only after the result is obtained.

Non-blocking: This function does not block the current thread until the result is immediately available and returns immediately.


How do I send HTTP requests with non-blocking I/O and return information?

http://jasonshieh.iteye.com/blog/927376


What are the buffer classes provided by non-blocking I/O?

Bytebuffer, Shortbuffer, Intbuffer, Charbuffer, Floatbuffer, DoubleBuffer, Longbuffer.


How do I read data from a buffer?
Bytebuffer.put (byte b);

Bytebuffer (int index, byte b);

Bytebuffer.put (byte[] src, int offset, int length);

Bytebuffer.array getting the data in the buffer


How do I label a special position in a buffer?

Use the Bytebuffer.mark method.


How do I use the WebView control to navigate backward through the history page?

Webview.goforward ();

Webview.goback ();


How do I display an HTML page in a WebView control?

Webview.loaddatawithbaseurl ();


How does JavaScript invoke the Java method?

By asynchronous completion, you use handler processing.


What is the way Android supports HTTP access?

Defaulthttpclient and HttpURLConnection, both encapsulate the HTTP request.


How do I send a POST request to the server through the HttpPost object and get the Java code for the string return value?

http://jasonshieh.iteye.com/blog/927376


How do I upload files using http?

http://blog.csdn.net/wangpeng047/article/details/38303865


What is WebService? Can Android call WebService?

WebService is an application that exposes an API that can be invoked through the web, which means that the application can be invoked programmatically through the Web.

Yes, but the Android SDK itself does not provide an API to call WebService, and requires the use of third-party APIs, such as KSOAP2.


What is HTTPS?

The Hypertext Transfer Protocol HTTP protocol is used to pass information between a Web browser and a Web server. The HTTP protocol sends content in plaintext, does not provide data encryption in any way, and if an attacker intercepts a transmission message between a Web browser and a Web server, it can read the information directly, so the HTTP protocol is not suitable for transmitting sensitive information such as credit card numbers, passwords, etc.

To address this flaw in the HTTP protocol, you need to use a different protocol: Secure Sockets Layer Hypertext Transfer Protocol HTTPS. For the security of data transmission, HTTPS joins the SSL protocol on the basis of HTTP, SSL relies on the certificate to verify the identity of the server, and encrypts the communication between the browser and the server.


How do I access HTTPS resources?

Http://blog.sina.com.cn/s/blog_6e4d9a9b0100wjt1.html


What is symmetric encryption? What is non-symmetric encryption?
The symmetric encryption algorithm uses the same secret key when encrypting and decrypting, while the asymmetric encryption algorithm requires two keys for encryption and decryption, both public and private keys, or public keys, or secret keys, which is the secret key (the private key).


What is an irreversible encryption algorithm? What kinds of irreversible encryption algorithms does Android support?

An irreversible cryptographic algorithm cannot be restored to its original data after it has been encrypted. Android supports MD5, SHA, HMAC, and so on.





"Android Interview Treasure" study notes (seventh: Network and encryption)

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.