1, network connection
(1) The user sends the request (Socket) to the server;
(2) The server sends a message to the user (ServerSocket), and listens for it. Accept ();
2, send and receive information
(1) The customer sends the message to the server: OutputStream OS = Clientsocket.getoutputstream (); PrintStream PS = new PrintStream (OS), package stream;
(2) The server receives user information: InputStream is = Client.getinputstream (); BufferedReader br = new BufferedReader (new InputStreamReader (IS));
(3) The server sends the message to the customer: similar (1);
(4) client receives server-side information: similar (2);
3, threading and multithreading
(1) Creating a new thread requires implements Runnable, which is required for thread initiation. Start ();
(2) Life cycle: New,runnable,not runnable (always listening, regular release, such as sleep, blocking), dead;
(3) Thread th = Thread.CurrentThread (); When the front-thread;
(4) The Run method will be executed by default after the thread is created;
(5) Get keyboard input: BufferedReader br = new BufferedReader (new InputStreamReader (system.in));
Java Network application Programming