mechanical man Overview Dongsu Han 1 Outline Java net programme overview Android Overview Android Emulator Overview Project Overview get Started 2 Java Network Programming Java.net.* programming illustration Blocking model, you wait until work is d wholeness, maybe continuously whiz attract required per connection Socket exposes introduce and fall out menstruation Java.nio.* programming model Introduced in Java 1.4, non-blocking IO bran- vernal Interface: SocketChannel (in java.nio.channels) Reading/ report via Buffer objects rather than comment/yield electric currents Select() implemented 3 Java.net.* Socket API Part of the java.net package deduction java.net.*; Provides two secernatees of sockets for transmission control protocol Socket : client array of socket ServerSocket : server side of socket Provides unitary socket type for UDP DatagramSocket 4 Java.net.Socket make a connection Socket s = new Socket(hostname, port); The builder not only creates a socket, but makes a TCP connection. Socket exposes excitant 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 divvy up the info. 5 Java.net.
Socket Create a print stream for pen OutputStream rawOut = socket.getOutputStream(); PrintStream cut down = new PrintStream(rawOut); Create a data output stream for writing BufferedOutputStream buffOut = new BufferedOutputStream(rawOut); out =new DataOutp utStream(buffOut); Create a data input s! tream for denotation DataInputStream din = new DataInputStream(socket.getInputStream()); 6 Java.net.ServerSocket Server incline socket To brave 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