Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Networking(I) 曾俊雄. Overview Java is a very good choice for networking programming. Client : – Socket – Applet – Java Web Start – Java Network Launch.

Similar presentations


Presentation on theme: "Java Networking(I) 曾俊雄. Overview Java is a very good choice for networking programming. Client : – Socket – Applet – Java Web Start – Java Network Launch."— Presentation transcript:

1 Java Networking(I) 曾俊雄

2 Overview Java is a very good choice for networking programming. Client : – Socket – Applet – Java Web Start – Java Network Launch Protocol

3 Overview(cont.) Server : – ServerSocket – Servlet – JSP Client & Server : – RMI – EJB – Soap – Web Service

4 Why Java Networking? Java is very suitable for network programming for the following reason : – Richness As previously discussed, we have many java- technologies for network programming. – Simplicity Traditionally, we use Berkerly socket for network programming, it is very complex, e.x., we will show an example to connect to network :

5 Why Java Networking?(cont.) family=AF_INET; connection=SOCK_STREAM; socketid=socket(family,connection,IPPROTO_TCP); struct hostent *hp; sockaddr1.sin_family=AF_INET; if(address[0]>='1' && address[0] ='0' && address[1]<='9') sockaddr1.sin_addr.s_addr=inet_addr(address); connect(socketid,(struct sockaddr *)(&sockaddr1),sizeof(sockaddr1)); With traditional socket library : With java : Socket socket=new Socket(address,port);

6 Why Java Networking?(cont.) – I/O functionality Java has great power in I/O , and network transmitting is just an I/O operation DataInputStream BufferedInputStream FileInputStream ByteArrayInputStream ObjectInputStream Network I/O stream

7 Why Java Networking?(cont.) – Naming ability There is an API called JNDI which is used for searching remote objects. This is very important for distributed computing, an important issue for network programming. – Platform independence This is also very important for distributed computing, since programs written on different platforms can co-work together easily.


Download ppt "Java Networking(I) 曾俊雄. Overview Java is a very good choice for networking programming. Client : – Socket – Applet – Java Web Start – Java Network Launch."

Similar presentations


Ads by Google