mechanical man Overview Dongsu Han 1 Outline Java electronic network programme overview Android Overview Android Emulator Overview Project Overview get Started 2 Java Network Programming Java.net.* programming fashion model Blocking model, you wait until work is d wholeness, maybe unceasingly whiz tramp required per connection Socket exposes introduce and yield menstruation Java.nio.* programming model Introduced in Java 1.4, non-blocking IO sore Interface: SocketChannel (in java.nio.channels) Reading/ report via Buffer objects rather than introduce/ create flows Select() implemented 3 Java.net.* Socket API Part of the java.net package entailment java.net.*; Provides two secernatees of sockets for transmission control protocol Socket : client situation of socket ServerSocket : server side of socket Provides unitary socket type for UDP DatagramSocket 4 Java.net.Socket make a connection Socket s = new-made Socket(hostname, port); The builder not only creates a socket, but makes a TCP connection. Socket exposes stimulation and output stream. s.getOutputStream() s.getInputStream() Most of the time youll chain the input/output stream to some other input/output stream or reader object to more considerably cargo area the entropy. 5 Java.net.
Socket Create a print stream for compose OutputStream rawOut = socket.getOutputStream(); PrintStream cut down = new PrintStream(rawOut); Create a data output stream for writing BufferedOutputStream buffOut = new BufferedOutputStream(rawOut); o ut =new DataOutputStream(buffOut); Creat! e a data input stream for recital DataInputStream din = new DataInputStream(socket.getInputStream()); 6 Java.net.ServerSocket Server incline socket To game multiple clients servers have at least one thread per client ServerSocket svr = new ServerSocket(port); while (Socket s = svr.accept()) { new EchoThread(s).start(); } 7 Java.net and Thread class EchoThread extends Thread { EchoThread(Socket s) { ... }...If you want to get a full essay, separate it on our website: OrderCustomPaper.com
If you want to get a full essay, visit our page: write my paper
No comments:
Post a Comment