Exceptions and networking

Slides:



Advertisements
Similar presentations
Umut Girit  One of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer.
Advertisements

CCNA – Network Fundamentals
Intermediate TCP/IP TCP Operation.
Network Layer and Transport Layer.
Socket Programming.
1 Java Networking – Part I CS , Spring 2008/9.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
System Programming Practical session 10 Java sockets.
Understanding Networks. Objectives Compare client and network operating systems Learn about local area network technologies, including Ethernet, Token.
Introduction To Networking
Networking Support In Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
TCP: Software for Reliable Communication. Spring 2002Computer Networks Applications Internet: a Collection of Disparate Networks Different goals: Speed,
What Is TCP/IP? The large collection of networking protocols and services called TCP/IP denotes far more than the combination of the two key protocols.
Process-to-Process Delivery:
Presentation on Osi & TCP/IP MODEL
Lecture 2 TCP/IP Protocol Suite Reference: TCP/IP Protocol Suite, 4 th Edition (chapter 2) 1.
Jaringan Komputer Dasar OSI Transport Layer Aurelio Rahmadian.
Internet Addresses. Universal Identifiers Universal Communication Service - Communication system which allows any host to communicate with any other host.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
Chapter Three Network Protocols By JD McGuire ARP Address Resolution Protocol Address Resolution Protocol The core protocol in the TCP/IP suite that.
RGEC MEERUT(IWT CS703) 1 Java Networking RGEC Meerut.
Chapter 6-2 the TCP/IP Layers. The four layers of the TCP/IP model are listed in Table 6-2. The layers are The four layers of the TCP/IP model are listed.
Chapter 15 – Part 2 Networks The Internal Operating System The Architecture of Computer Hardware and Systems Software: An Information Technology Approach.
Application Layer Khondaker Abdullah-Al-Mamun Lecturer, CSE Instructor, CNAP AUST.
TCP/IP (Transmission Control Protocol / Internet Protocol)
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
1 OSI and TCP/IP Models. 2 TCP/IP Encapsulation (Packet) (Frame)
IP addresses IPv4 and IPv6. IP addresses (IP=Internet Protocol) Each computer connected to the Internet must have a unique IP address.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
1 Kyung Hee University Chapter 11 User Datagram Protocol.
The OSI Model. Understanding the OSI Model In early 1980s, manufacturers began to standardize networking so that networks from different manufacturers.
SOCKET PROGRAMMING Presented By : Divya Sharma.
Understand IPv6 Part 2 LESSON 3.3_B Networking Fundamentals.
Application Layer Functionality and Protocols Abdul Hadi Alaidi
Chapter 7: Transport Layer
Chapter 11 User Datagram Protocol
LESSON Networking Fundamentals Understand TCP/IP.
Chapter 9: Transport Layer
Instructor Materials Chapter 9: Transport Layer
Transport Protocols Relates to Lab 5. An overview of the transport protocols of the TCP/IP protocol suite. Also, a short discussion of UDP.
MCA – 405 Elective –I (A) Java Programming & Technology
Lecture 6: TCP/IP Networking By: Adal Alashban
TCP Transport layer Er. Vikram Dhiman LPU.
NET323 D: Network Protocols
Client-Server Interaction
Subject Name: Computer Communication Networks Subject Code: 10EC71
Packet Switching To improve the efficiency of transferring information over a shared communication line, messages are divided into fixed-sized, numbered.
The Internet and HTTP and DNS Examples
Chapter 14 User Datagram Protocol (UDP)
Transport Protocols Relates to Lab 5. An overview of the transport protocols of the TCP/IP protocol suite. Also, a short discussion of UDP.
I. Basic Network Concepts
Transport Protocols Relates to Lab 5. An overview of the transport protocols of the TCP/IP protocol suite. Also, a short discussion of UDP.
NET323 D: Network Protocols
Process-to-Process Delivery:
TCP/IP Protocol Suite: Review
Transport Protocols An overview of the transport protocols of the TCP/IP protocol suite. Also, a short discussion of UDP.
Starting TCP Connection – A High Level View
Chapter 15 – Part 2 Networks The Internal Operating System
TCP/IP Protocol Suite: Review
Networking Theory (part 2)
Net 323 D: Networks Protocols
1 TRANSMISSION CONTROL PROTOCOL / INTERNET PROTOCOL (TCP/IP) K. PALANIVEL Systems Analyst, Computer Centre Pondicherry University, Puducherry –
CSCD 330 Network Programming
Delivering the Data.
Process-to-Process Delivery: UDP, TCP
Computer Networks Protocols
OSI Model 7 Layers 7. Application Layer 6. Presentation Layer
Transport Protocols Relates to Lab 5. An overview of the transport protocols of the TCP/IP protocol suite. Also, a short discussion of UDP.
Networking Theory (part 2)
Presentation transcript:

Exceptions and networking SPL – PS9 Exceptions and networking

Overview Exceptions Internet protocol Java sockets

Exceptions Java uses exceptions to handle errors and other exceptional events. For example, reading a file that doesn’t exist, dividing by zero, networks problem, and an attempt to access an element out of the array’s bounds.

Exceptions (cont) When an error occurs within a method, the method creates an object and hands it off to the runtime system. The object, called an exception, contains information about the error. After an exception was thrown, the runtime system attempts to find someone to handle it. By searching the call stack in reverse order looking for a block of code that can handle the exception. If no such block of code was found, the exception is passed to the JVM which terminates the program.

Exceptions types There are two types of exceptions, unchecked exceptions and checked exceptions. Unchecked exceptions could be divided into errors, and runtime exceptions. Unchecked exceptions usually indicate conditions which the application cannot anticipate or recover from. Checked exceptions are conditions which a well-written application should anticipate and recover from. For example, not finding a file.

Exceptions types (cont)

Creating new exceptions

Handling exceptions When handling exceptions, we could do one of the following: Change conditions and retry again. Clean up and rethrow exception, for example when attempting to open a file that doesn’t exist.

The finally block The finally block comes right after all catch block in a try-catch clause. The code in the finally block is always executed before exiting the try- catch clause, even if an exception occurred, or return/continue/break statement was encountered.

Try with resources Instead of using the finally block, since Java 7 we have the possibility of try with resources. An object that implements the interface AutoCloseable can be declared as part of the try statement.

The Internet The Internet is a global system of interconnected computer networks. Every machine on the Internet has a unique identifying number, called an IP address. The IP stands for Internet Protocol, which is the language that computers use to communicate over the Internet. The original designers of TCP/IP defined an IP address as a 32bit number, this system is known as IPv4. Due to the enormous growth of the Internet, a new system called IPv6 using 128 bits for the address was introduced.

TCP/IP model The TCP/IP model is a description framework for computer network protocols. TCP/IP provides end-to-end connectivity specifying how data should be formatted, addressed, transmitted, routed and received at the destination. TCP/IP generally described as having four abstraction layers: Link Layer Internet Layer Transport Layer Application Layer

Special IP addresses There are some special IP addresses: 0.0.0.0 – is reserved for the default network. 255.255.255.255 – is used for broadcasts (Messages that are intended for all computers on a network) 127.0.0.1 – is used for loopback address. That means it is used by the computer to send a message back to itself. Also aliased as localhost.

Domain Name Systems (DNS) Remembering IP addresses is hard for humans. The DNS service maps text names to IP addresses automatically. An helpful analogy is to think of the DNS service as a phone book of the internet, which translates user-friendly addresses to IP addresses.

Internet Servers and Clients All of the machines in the Internet are either servers or clients (or both). Machines that provides services are servers, and machines which are used to connect to those services are clients.

Ports Any server machine makes it’s service available using numbered ports – one for each service available on the server. You can think as the IP:Port combo as this: The IP is the building address, and the Port is the apartment number. For example, if a server machine is running a web server and a file transfer protocol, the web server will typically be available in port 80, and the FTP server will be available in port 21.

Sockets Sometimes applications require low-level communication, for example, connecting to a database, or implementing instant messaging. Networking allows processes running on different hosts to exchange messages, using sockets. When messages are sent, they are queued at the sending socket until the network protocol has transmitted them.

Datagram Communication The datagram communication protocol known as UDP (user datagram protocol), is a connectionless protocol – meaning that the datagram can be sent at any moment without prior connection preparation as in TCP. There is no guarantee that the datagram will be delivered, or that datagrams will be delivered in correct order. The main advantage of UDP is that you can broadcast, and that it is fast, the main disadvantage is that it is unreliable.

The stream communication The stream communication protocol is known as TCP (transfer control protocol). Unlike UDP, TCP is a connection-oriented protocol, meaning that a connection must be established between the two pair of sockets before messages can be sent. Guaranteed that all data sent will be received, without any error and in the correct order.

The Client-Server Model The client-server model is a very common model in many networking applications. The server provides some service, and the client uses the service provided by the server. A socket connection is established between server and client on top of a TCP-connection.

The Client-Server Model (cont) To establish a connection, the model determines that: The server waits for connection requests from clients. The server only reacts to the initiative of the client. To remain available for further connections, the server doesn’t open the connection directly with the client on the incoming socket. Instead, it creates a private socket which the client can keep connected for the whole period of the session. Servers must be built to maximize availability – They must handle requests for connections as fast as possible, and then return to the mode where they can receive and handle more requests from clients.

Text encoding Different computers, runtime environments, languages and compilers use different symbols representation. If a server expects the text to be encoded in ASCII, and the client sends it in UTF-8, this would cause a problem. We can create the readers and writers with the encoding specified

The Protocol Interface We don’t want to hold the implementation of a protocol inside the server’s code, since handling the communication is complex enough. For that purpose, we can define an interface MessagingProtocol.