Presentation is loading. Please wait.

Presentation is loading. Please wait.

Networking Mehdi Einali Advanced Programming in Java 1.

Similar presentations


Presentation on theme: "Networking Mehdi Einali Advanced Programming in Java 1."— Presentation transcript:

1 Networking Mehdi Einali Advanced Programming in Java 1

2 2 agenda Basic Concepts on Networking IP Address Protocol Ports The Client/Server Paradigm Sockets The Java Networking Package The ServerSocket and the Socket Class The MulticastSocket and the DatagramPacket Class

3 3 Networking

4 4 Basic Concepts on Networking The Internet A global network of computers connected together in various ways Remains functional despite of diversity of hardware and software connected together Possible through communication standards defined and conformed to Guarantee compatibility and reliability of communication

5 5 IP Address Logically similar to the traditional mailing address An address uniquely identifies a particular object Each computer connected to the Internet has a unique IP address (Version 4) A 32-bit number used to uniquely identify each computer connected to the Internet 192.1.1.1 docs.rinet.ru(via dns) 4294967296 (2 32 ) addresses Pv6 uses a 128-bit address, theoretically allowing 2 128, or approximately 3.4×10 38 addresses

6 6 Protocol Why protocols? Different types of communication occurring over the Internet Each type of communication requires a specific and unique protocol Definition Set of rules and standards that define a certain type of Internet communication

7 7 Protocol-2 Consider this type of conversation: "Hello." "Hello. Good afternoon. May I please speak at Joan?" "Okay, please wait for a while." "Thanks.“ Social protocol used in a telephone conversation Gives us confidence and familiarity of knowing what to do

8 8 Protocol stack Paper and Pen Persian Alphabet Formal Letter Loan Request Persian Language Envelope Envelope Package Paper and Pen Persian Alphabet Formal Letter Loan Request Persian Language Envelope Envelope Package Post Cargo Tehran INOC Accounting Loan Manager

9 9 Network protocol stack

10 10 Net protocols Some important protocols used over the Internet Hypertext Transfer Protocol (HTTP) Used to transfer HTML documents on the Web File Transfer Protocol (FTP) More general compared to HTTP Allows you to transfer binary files over the Internet Both protocols have their own set of rules and standards on how data is transferred Java provides support for both protocols

11 11 Ports Protocols only make sense when used in the context of a service HTTP protocol is used when you are providing Web content through an HTTP service Each computer on the Internet can provide a variety of services Why Ports? Ports locate appropriate process with is responsible to service A 16-bit number that identifies each service offered by a network server 80 : http, 21: ftp Given port values below 1024

12 12 Ports 192.168.1.2 192.168.1.3 192.168.1.123 192.168.1.1 90.98.210.156

13 13 Transport layer protocols TCPUDP Acronym for Transmission Control Protocol User Datagram Protocol or Universal Datagram Protocol Connection TCP is a connection- oriented protocol. UDP is a connectionless protocol Usage TCP is suited for applications that require high reliability, and transmission time is relatively less critical. UDP is suitable for applications that need fast, efficient transmission, such as games. UDP's stateless nature is also useful for servers that answer small queries from huge numbers of clients Use by other protocols HTTP, HTTPs, FTP, SMTP, Telnet DNS, DHCP, TFTP, SNMP, RIP, VOIP.Ping Java Classes ServerSocket, SocketDatagramSocket,DatagramPacket

14 14 Java network api

15 15 url vs socket Socket programing Working with sockets to do network operation. It work on transportation layer(building its own application based on it) URL processing Work with URL objects Based on HTTP protocol( don’t need to work with underlying transport layer e.g. sockets)

16 16 socket Definitions: Software abstraction for an input or output medium of communication Communication channels that enable you to transfer data through a particular port An endpoint for communication between two machines A particular type of network communication used in most Java network programming Java performs all of its low-level network communication through sockets

17 17 The ServerSocket Class

18 18

19 19

20 20 The Socket Class

21 21

22 22

23 23

24 24

25 25 end


Download ppt "Networking Mehdi Einali Advanced Programming in Java 1."

Similar presentations


Ads by Google