Networking CSI 3125 Preliminaries page 1 Networking A

  • Slides: 13
Download presentation
Networking CSI 3125, Preliminaries, page 1

Networking CSI 3125, Preliminaries, page 1

Networking • A network represents interconnection of computers that is capable of sharing files

Networking • A network represents interconnection of computers that is capable of sharing files and information between multiple systems. • The computer which receives service is called client and • The computer which provides service is called server. • The term network programming refers to writing programs that execute across multiple devices (computers), in which the devices are all connected to each other using a network. • There is a unique identification number called IP address (Internet Protocol) allotted to every computer on a network or Internet. • An IP address consists of four dotted decimal numbers between 0 and 255, such as 130. 254. 204. 36. CSI 3125, Preliminaries, page 2

Networking • The computers in a network make use of this IP address in

Networking • The computers in a network make use of this IP address in order to communicate with each other. • Since it is not easy to remember an IP address, they are often mapped to meaningful names called domain names or hostnames. • Special servers called Domain Name Servers (DNS) are available on the Internet that translate host names into IP addresses. CSI 3125, Preliminaries, page 3

Networking • When a computer specifies a site address, it first asks the DNS

Networking • When a computer specifies a site address, it first asks the DNS to translate this domain name into a numeric IP address and then sends the request using the IP address. • Need to specify certain set of rules to communicates with another system. • A protocol is a set of rules defining how computers communicate: such as the format of addresses, how data is split into packets, etc. CSI 3125, Preliminaries, page 4

Networking • There are many different protocols defining different aspects of network communication. •

Networking • There are many different protocols defining different aspects of network communication. • For example HTTP is used to transfer HTML documents on the Web and • FTP allows you to transfer binary files over the Internet. • Both protocols have their own set of rules and standards on how data is transferred. CSI 3125, Preliminaries, page 5

Networking • Each computer with an IP address has several thousand logical ports •

Networking • Each computer with an IP address has several thousand logical ports • Each computer on the internet can provide a variety of services and the type of service • Each port is identified by a number from 1 to 65, 535. • and each port can be allocated to a particular service. • For example, the HTTP service, generally runs on port 80: • we say that a web server listens on port 80 for incoming connections. • SMTP or email servers run on port 25. CSI 3125, Preliminaries, page 6

Networking • When data is sent to a web server on a particular machine

Networking • When data is sent to a web server on a particular machine at a particular IP address, it is also sent to a particular port on that machine. • The receiver checks each packet it sees for the port and sends the data to any programs that are listening to the specified port. • Port numbers from 1 to 1023 are reserved for well-known services such as FTP, HTTP, and email. CSI 3125, Preliminaries, page 7

Socket Communication • The socket is the software abstraction used to represent the "terminals"

Socket Communication • The socket is the software abstraction used to represent the "terminals" of a connection between two machines. • Network programming usually involves a server and one or more clients. • The client sends requests for information/services own by the Server. • Once the connection is established between Client and Server, they can start sending / receiving information. • Socket acts as an interface between sever and client • It create a communication channel • A programmer can use that channel to send data between the two machines. CSI 3125, Preliminaries, page 8

Socket Communication • Java treats socket communications as I/O operations; thus programs can read

Socket Communication • Java treats socket communications as I/O operations; thus programs can read from or write to sockets. • The socket associates the server program with a specific port on the machine where it runs so any client program anywhere in the network with a socket associated with that same port can communicate with the server program. • The server waits and listens to the socket for a client to make a connection request CSI 3125, Preliminaries, page 9

Socket Communication CSI 3125, Preliminaries, page 10

Socket Communication CSI 3125, Preliminaries, page 10

Client Server Comminication • The server accepts the connection request from client which contains

Client Server Comminication • The server accepts the connection request from client which contains the name of the server and port number. • Upon acceptance, the server creates a new socket bound to a different port and this new socket is dedicated for serving the client that had sent request. • The original socket can continue to listen for further connection requests CSI 3125, Preliminaries, page 11

Client Server Comminication CSI 3125, Preliminaries, page 12

Client Server Comminication CSI 3125, Preliminaries, page 12

The Java Networking Package • The java. net package contains a collection of classes

The Java Networking Package • The java. net package contains a collection of classes and interfaces that provide functionalities for writing programs • Some of the important classes available in java. net Package are: • Inet. Address • Server. Socket • Datagram. Packet • Datagram. Socket • URL CSI 3125, Preliminaries, page 13