Você está na página 1de 23

D7001D Network Programming and

Distributed Applications

Lecture 1!

Introduction!
Why Networked Java?!
Introduction

D7001D Network programming and distributed applications!

Robert Brännström!
robert.brannstrom@ltu.se!

Examination!

Type ! !Credits !Grade !


Written exam !3.0 !F 3 4 5 !
Seminar! !1.5 !F P !
Laboratory work !3.0 !F P!
Course litterature

Java Network Programming, 3ed!


Elliotte Rusty Harold!
www.oreillly.com!

ISBN-10: 0-596-00721-3!
ISBN-13: 978-0-596-00721-8!

Link to sourse code in Fronter!


Labs

4 assignments !

Individual implementation and demonstration.!


Lab report posted in Fronter before deadline.!

Lab assistant!
Karan Mitra karan.mitra@ltu.se!
Course materials

Virtual classroom in Fronter!


- lectures!
- labs!
- supplementary materials!

http://www.fronter.com/ltu!

Access to students registered on the course!


COURSE SYLLABUS

Course aim!
This course gives the student knowledge to program applications containing
network communication.!

Course content!
The course covers network communication and discusses basic structures and
functionalities for development of networking applications. In addition,
the course introduces communication models like TCP/IP and its support
protocols, client-server, peer-to-peer, VPN and NAT. The course also
establishes knowledge for programming of parallel events with threads,
timers and counters.!

Who are you?!


- student presentations (name, country, short edu. background)!
Chapter 1

Why Networked Java?


Why Networked Java?

Network programming is today a natural part of the programmers


toolbox.!

Most applications contains some type of communication.!


-  open/save documents on a file server!
-  Links (URL:s) in a text document!
-  Download updates!

Any type of application can be written in Java!


Java

The language was designed with network communication in mind.!

One of the first applications written in Java was a web browser. !

•  Platform independent !
•  Security!

It is easier to write networked programs in Java than in most other


languages.!

The network part is often just a small part of the application. !


The biggest part is often data processing and the user interface.!
What can a network program do?

Networking = power!
Possibilities to communicate with millions of computers… !

Systems are often divided in client and server parts.!


-  A simple client will receive data from a server and dislay it to the user!
-  More advanced clients will process the data and might communicate
with several servers to receive updates !
-  A simple server just return a file from the file system to the client!
-  More advanced servers perform advanced processing of data!
-  A peer-to-peer application is both a client and a server!
Collecting data

Data fetched from a server…!


•  Displayed to the user!
•  Stored in a local database or on file!
•  Combined with other data!
•  Analyse the data!
…or a combination …!

Java supports standard application protocols like HTTP, FTP, SMTP, …!


- and enables creation of specialised protocols!
Collecting data…

Standardised protocols can be used for other purposes than planed.!


- An HTTP request does not have to be for an HTML file…!
(XML, binary)!

The file does not have to be displayed in a browser window…!


- The client can process the file content for other purposes!

Clients can collect data from several servers!


- RSS feeds!

Java GUI programming!


- More than just HTML in a browser!
- Tables, Graphs, 3D…!
Network communication

Not just for information to humans…!

Web services offer access to data formatted in a predefined way. XML files are
often sent via HTTP.!

Network communication in Java = streams (equal to handle I/O, files)!


- Read and write methods!

Predefined Java classes for TCP and UDP communication!


- IP address and port number !Socket s = new Socket(”130.240.136.144”, 80);

Java only supports IP communication!


- Do NOT offer access to direct IP packets!
- TCP/IP - ”lingua franca” [defacto standard]!
Sending data

To send data is as easy as fetching data…!

Send files/data: HTTP POST, FTP, SOAP…!


- Standard format (jpeg, gif, text, mime)!
- Client and server must speak the same ”language”!

Massively parallel computing (Grid)!


- Separate tasks on several computers instead of buying a faster
servers!
- Borrow ”unused” CPU resources… (locally/Internet)!
Peer-to-peer

Applications that are both clients and servers!


- Often a server is involved at start-up (login)!

•  Games!
•  Chat !
•  File sharing!
•  WebCollab!
Servers

Applications listening for incoming connections…!


Socket newConnection = serverSocker.acept(); //blocking for client connection

All types of servers can be written in Java (most types are already implemented)!
- I lab 3 you will construct an game server…!

Java Remote Method Invocation (RMI) => objects on the server can be called
directly from the code in the client (like an local object).!

The Java Servlet API enables adding of new services to the existing server.!
Spiders and Agents

A “spider” is a program that “crawls” the web, loading page after


page, following each link on every page…!
- This is used e.g. to index web pages in a database, to perform
lexicographically analysis, to find specific information, etc. !
- Should not be performed on the whole Internet… !
(OK locally or with controlled depth)!

An agent is a program that moves between computers…!


- It run its code locally on the current computer and then moves !
- Java has security support enabling mobile agents!

Java also has support for electronic transactions!


- Secure and encrypted payment solutions!
Interactive environments

Java 2 Micro Edition (J2ME or Java Mobile) is a subset of the Java 2 API.!
- targets small units like set-top boxes, mobiles, PDAs…!
- no support for java.net classes !
- has instead a Generic Connection Framework !

The Java TV API extends J2ME !


- switching channels, streaming sound/video…!
- interactive TV services!

The Java Media Framework (JMF) is a whole library of media


support. Enables recording, playback, streaming and encoding
of a number of media formats.!
What happens when we surf the
Internet?
-  in the application!
-  in the computer OS!
-  in the network!

-  when you write an URL in the web browser!


What happens when we surf the
Internet?
Network protocol stack
Domain Name System (DNS)

A name server translates domain names (www.ltu.se) to IP addresses (130.240.42.55).!


Manages other domain information (email servers etc.)!

! ! ! ! ! ! ! !13 root servers!

! ! ! ! ! ! ! !top domains!

! ! ! ! ! ! ! !sub domains!
Next lecture

Basic Network Concepts!

Network protocol stack, an architecture in several layers!


TCP/IP vs. OSI models!
IP addresses and port numbers!
Different network units, their tasks, protocols and layers !
NAT and fire walls!
Internet standards…!

Você também pode gostar